NAME
SignalWire::ML - Light and fast SWML generator
METHODS
new($class, $args)
Constructor method. Creates a new SignalWire::ML object with default values.
Example
Here's an example of how to use SignalWire::ML:
use
SignalWire::ML;
# Create a new SignalWire::ML object
my
$ml
= SignalWire::ML->new({
version
=>
'1.0.0'
});
# Set AI prompt
$ml
->set_aiprompt({
text
=>
"What's the weather like today?"
,
temperature
=> 0.7,
top_p
=> 0.9
});
# Set AI parameters
$ml
->set_aiparams({
max_tokens
=> 150
});
# Add an AI application to a section
$ml
->add_aiapplication(
'main'
);
# Render the result
my
$json_output
=
$ml
->render_json();
$json_output
;
This example demonstrates creating a SignalWire::ML object, setting various parameters and contexts, adding applications, and then rendering the result as JSON.
add_aiapplication($self, $section)
Adds an AI application to the specified section.
set_context_steps($self, $context_name, $steps)
Sets the steps for a specific context in the prompt.
add_context_steps($self, $context_name, $steps)
Adds steps to an existing context in the prompt.
set_prompt_contexts($self, $contexts)
Sets the contexts for the prompt.
add_application($self, $section, $app, $args)
Adds an application to the specified section with given arguments.
This method is used to add an application to a specific section in the SignalWire::ML object.
Example usage:
my
$swml
= SignalWire::ML->new({
version
=>
'1.0.0'
});
$swml
->add_application(
"main"
,
"answer"
);
$swml
->add_application(
"main"
,
"play"
,
{
urls
=> [
"https://github.com/freeswitch/freeswitch-sounds/raw/master/en/us/callie/ivr/48000/ivr-welcome_to_freeswitch.wav"
] });
$swml
->add_application(
"main"
,
"hangup"
);
$swml
->add_aiapplication(
'main'
);
$swml
->render_json;
This example demonstrates creating a SignalWire::ML object, adding various applications including an answer, play, and hangup application, then adding an AI application to the 'main' section, and finally rendering the result as JSON.
set_aipost_prompt_url($self, $postprompt)
Sets the AI post-prompt URL and related parameters.
set_global_data($self, $data)
Sets the global data for the ML object.
set_aiparams($self, $params)
Sets the AI parameters.
add_aiparams($self, $params)
Adds additional AI parameters.
set_aipost_prompt($self, $postprompt)
Sets the AI post-prompt parameters.
set_aiprompt($self, $prompt)
Sets the AI prompt parameters.
swaig_response($self, $response)
Processes and returns the SWAIG response.
swaig_response_json($self, $response)
Processes the SWAIG response and returns it as JSON.
render($self)
Renders the content of the ML object.
render_json($self)
Renders the content of the ML object as JSON.
render_yaml($self)
Renders the content of the ML object as YAML.
SYNOPSIS
TODO