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
-
Name
- Duration
- Description: Length of the meditation session in minutes.
- Example value: 10
-
Name
- Type
- Description: Type of meditation (e.g., mindfulness, guided, music-based).
- Example value: Mindfulness
Environment Variables
-
Name
- Audio Generation API Key
- Description: API key for the service that generates meditation audio.
- Value: YOUR_API_KEY_HERE
-
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.