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.

There are several major issues with the code you shared.

1st, I see you’re trying to create the audio streaming meditation thing here. It’s not likely to work if you implement it this way since Pickaxe does not yet support audio streaming. That can be a popular Feature request! You have my vote if you post it.

There is a potential workaround for audio streaming with a script that you can attach to your studio. I might be able to help you with that. Send me a DM if you’re interested.

2nd, you’re pasting the import os and import requests too many times.

Here is an example of Python action-code that you can give to your favorite AI tool to use as a template:

Mind the spacing. If you get these wrong, it will cause a syntax error, and your code will not work properly.

Anything under the red line can be deleted or edited (anything within the yellow square). Anything above (or out of the yellow square) cannot - you’ll have to configure it in the ‘Action details’ section.

My code (for a basic make webhook):

import os
import requests
import logging

def linkedin_optimization_make_webhook(linkedin_url: str):
    """
    Sends a basic request with data payloads to a make.com webhook

    Args:
        linkedin_url (string): The URL of the user’s LinkedIn profile to be analyzed and scored.
    Envs:
        MAKE_COM_WEBHOOK (string): Webhook link from Make.com
    """

    
    make_url = os.getenv("MAKE_COM_WEBHOOK")
    if not make_url:
        error_msg = "MAKE_COM_WEBHOOK environment variable is not set."
        logging.error(error_msg)
        return {"error": error_msg}

    data_to_send = {
        "linkedin_url": linkedin_url
    }

    try:
        response = requests.post(make_url, json=data_to_send, timeout=60)
        response.raise_for_status()

        # Try to parse the JSON response from Make
        try:
            result = response.json()
            return result  # Return the full data for Pickaxe/code interpreter
        except ValueError:
            # Not a JSON response, just text
            logging.warning("Received non-JSON response from Make.")
            return {"error": "Make returned non-JSON response.", "response": response.text}

    except requests.exceptions.RequestException as req_err:
        logging.error(f"Request error sending data to Make: {req_err}")
        return {"error": f"Failed to send data to Make. Error: {req_err}"}

    except Exception as e:
        logging.error(f"Unexpected error: {e}")
        return {"error": f"An unexpected error occurred: {e}"}```

Hi Ned,
yes, I pasted the import os and import requests too many times to display the problem of this editor. I pasted and then wasn´t able to delete it again. It just stays there and can´t be deleted. So I try to paste code, and then I´m not able to get rid of it and to erase the error.

Do you understand? I hope I could make myself clear now.

1 Like

Yes @sitedude I understand you. I used to run into these issues when I first started with Pickaxe. I recall I used to just delete the action and redo it from scratch. Always worked

sure, that´s a workaround, but annoying as hell. Can we tag someone from the admin team, so they can fix this issue? @admin_mike would that be you?