Action Code is not editable

Tried to paste some code into the action code, but the editor doesn´t work properly. Doesn´t allow me to paste, sometimes it works, doesn´t allow me to delete, only certain parts. It even doesn´t allow me to delete text, that I´ve pasted before for example:

 import os
import requests

When I try to delete, the text line just jumps over the characters, but doesn´t delete them. I understand, that certain basic functions are as presets in the code, but please allow us to edit this code completely. Currently, this is not working.

1 Like

I had the same issue. Very frustrating.

1 Like

@sitedude @charles_st_george That’s not a bug. The import components of the Python code are not editable in Pickaxe by design.

The idea is to allow non-technical users to use the 'Action Details’ section to hardcode the critical data into the code that you can partially edit under the ‘Action code’ section. Any of the 3 components marked with a red arrow in the screenshot below can be manually configured by you - whatever changes you make here will become hardcoded into the Action code.

You can add more libraries/packages to the code that will appear under

import os
import requests
  • by utilizing the ‘Additional Packages’ section.

Essentially anything above the red line is uneditable within the Action code section within the Pickaxe ecosystem.

Hi Ned,
thank you for your clarification, but I´m a non-coding user. I have used a pickaxe from someone else that helps with custom actions. So I copied this AI generated code (see below), and thought this would work. But no. It does not only not work, it also doesn´t allow me to delete the code, I´ve just entered. Only certain parts. After trying this several times in the window, I am stuck with this code that I can´t delete. The more often I paste my original code, the more code i won´t be able to delete:

import requests
def generate_meditation_audio(duration: str, type: str):
    """
    Creates a personalized meditation audio based on user input and starts the meditation with a modern interface.



    Args:
        duration (string): Length of the meditation session in minutes.
        type (string): Type of meditation (e.g., mindfulness, guided, music-based).
    Envs:
        AUDIO_GENERATION_API_KEY (string): API key for the service that generates meditation audio.
        AUDIO_STORAGE_PATH (string): Path where the generated audio will be stored or accessed.
    """

import os
import requests

import os
import requests
def generate_meditation_audio(duration: str, meditation_type: str):
    """
    Generates a meditation audio file based on the user's preferences.

    Args:
        duration (string): Length of the meditation session in minutes.
        meditation_type (string): Type of meditation (e.g., mindfulness, guided, music-based).

    Envs:
        Audio_Generation_API_Key (string): API key for the service that generates meditation audio.
        Audio_Storage_Path (string): Path where the generated audio will be stored or accessed.
    """

    api_key = os.getenv('Audio_Generation_API_Key')

    import os
import requests

def generate_meditation_audio(duration: str, meditation_type: str):
    """
    Generates a meditation audio file based on the user's preferences.

    Args:
        duration (string): Length of the meditation session in minutes.
        meditation_type (string): Type of meditation (e.g., mindfulness, guided, music-based).

    Envs:
        Audio_Generation_API_Key (string): API key for the service that generates meditation audio.
        Audio_Storage_Path (string): Path where the generated audio will be stored or accessed.
    """

    api_key = os.getenv('Audio_Generation_API_Key')

According to his bot, I should use the following setup for my custom action:

Yes, it’s possible to create a custom action for generating a meditation audio output based on user input. Here’s how you can set it up in Pickaxe:

Name

Generate Meditation Audio

Description

Creates a personalized meditation audio based on user input and starts the meditation with a modern interface.

Trigger Prompt

When a user indicates they want to start a meditation session, prompt them to specify their preferences (e.g., duration, type of meditation). Once received, generate a customized meditation audio and present it with a “Start Meditation” button in a modern design.

Function Inputs

  1. Name

    • Duration
    • Description: Length of the meditation session in minutes.
    • Example value: 10
  2. Name

    • Type
    • Description: Type of meditation (e.g., mindfulness, guided, music-based).
    • Example value: Mindfulness

Environment Variables

  1. Name

    • Audio Generation API Key
    • Description: API key for the service that generates meditation audio.
    • Value: YOUR_API_KEY_HERE
  2. Name

    • Audio Storage Path
    • Description: Path where the generated audio will be stored or accessed.
    • Value: /path/to/audio/storage/

Python Code for the Custom Function

import os
import requests

def generate_meditation_audio(duration: str, meditation_type: str):
    """
    Generates a meditation audio file based on the user's preferences.

    Args:
        duration (string): Length of the meditation session in minutes.
        meditation_type (string): Type of meditation (e.g., mindfulness, guided, music-based).

    Envs:
        Audio_Generation_API_Key (string): API key for the service that generates meditation audio.
        Audio_Storage_Path (string): Path where the generated audio will be stored or accessed.
    """

    api_key = os.getenv('Audio_Generation_API_Key')
    audio_storage_path = os.getenv('Audio_Storage_Path')

    # Make a request to the audio generation API
    response = requests.post(
        'https://api.meditationaudio.com/generate',
        json={
            'duration': duration,
            'type': meditation_type
        },
        headers={'Authorization': f'Bearer {api_key}'}
    )

    if response.status_code == 200:
        audio_data = response.content
        # Save the audio file
        audio_file_path = os.path.join(audio_storage_path, 'meditation_audio.mp3')
        with open(audio_file_path, 'wb') as audio_file:
            audio_file.write(audio_data)
        return audio_file_path
    else:
        raise Exception("Failed to generate meditation audio. Please check your inputs and API key.")

# Instructions for Custom Bot Creation
# 1. Define the trigger prompt to capture user inputs for duration and meditation type.
# 2. Set up the required environment variables with your API key and desired storage path.
# 3. Implement the function using the provided Python code, and ensure you handle any exceptions.
# 4. Design the UI with a modern button labeled "Start Meditation" that triggers the function.