Agents 1.4.0
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::VoiceAgent Class Reference

Voice agent that inherits from AutonomousAgent and adds voice capabilities. More...

#include <voice_agent.h>

Inheritance diagram for agents::VoiceAgent:
agents::AutonomousAgent agents::Agent

Public Types

enum class  PlanningStrategy {
  ZERO_SHOT ,
  TREE_OF_THOUGHT ,
  PLAN_AND_EXECUTE ,
  REFLEXION ,
  REACT
}
 Planning strategy for the agent. More...
enum class  State {
  READY ,
  RUNNING ,
  WAITING ,
  COMPLETED ,
  FAILED ,
  STOPPED
}
 Agent execution state. More...

Public Member Functions

 VoiceAgent (std::shared_ptr< Context > context, const VoiceConfig &config)
 Constructor.
 ~VoiceAgent () override
 Destructor.
void init () override
 Initialize the agent.
void listen ()
 Listen for voice input.
void stopListening ()
 Stop listening for voice input.
Task< JsonObjectrun (const std::string &task) override
 Run the agent with a task using coroutines.
void runAsync (const std::string &task, std::function< void(const JsonObject &)> callback) override
 Run the agent with a callback.
void stop () override
 Stop the agent.
void provideFeedback (const std::string &feedback) override
 Provide human feedback.
void setAgentPrompt (const std::string &agent_prompt)
 Set the agent prompt.
void setPlanningStrategy (PlanningStrategy strategy)
 Set the planning strategy.
std::vector< StepgetSteps () const
 Get the steps executed so far.
void setStepCallback (std::function< void(const Step &)> callback)
 Set a callback for when a step is completed.
Task< std::string > waitForFeedback (const std::string &message, const JsonObject &context) override
 Wait for feedback using coroutines.
std::shared_ptr< ContextgetContext () const
 Get the agent's context.
State getState () const
 Get the agent's current state.
void setOptions (const Options &options)
 Set execution options.
const OptionsgetOptions () const
 Get execution options.
void setStatusCallback (std::function< void(const std::string &)> callback)
 Set a callback for status updates.

Protected Member Functions

Task< JsonObjectexecuteTask (const std::string &task)
 Execute the agent's task using coroutines.
Task< StepexecuteStep (std::string &step_description, JsonObject &context)
 Execute a step using coroutines.
void recordStep (const Step &step)
 Record a completed step.
std::string getToolDescriptions () const
 Get tool descriptions for prompts.
Task< JsonObjectplanZeroShot (const std::string &task)
 Plan using Zero Shot.
Task< JsonObjectplanTreeOfThought (const std::string &task)
 Plan using Tree of Thought.
Task< JsonObjectplanAndExecute (const std::string &task)
 Plan and execute.
Task< JsonObjectplanReflexion (const std::string &task)
 Plan using Reflexion.
Task< JsonObjectplanReact (const std::string &task)
 Plan using React.

Protected Attributes

std::string agent_prompt_
 The agent prompt.
PlanningStrategy planning_strategy_ = PlanningStrategy::REACT
 Planning strategy for the agent.
std::vector< Stepsteps_
 The steps executed so far.
std::function< void(const Step &)> step_callback_
 Callback for when a step is completed.
std::function< void(const JsonObject &)> task_callback_
 Callback for task's incremental updates.
std::atomic< bool > should_stop_ {false}
 Execution state flag to indicate if the agent should stop.
std::promise< std::string > feedback_promise_
 Promise for coroutine-based feedback.

Detailed Description

Voice agent that inherits from AutonomousAgent and adds voice capabilities.

Member Enumeration Documentation

◆ PlanningStrategy

enum class agents::AutonomousAgent::PlanningStrategy
stronginherited

Planning strategy for the agent.

Enumerator
ZERO_SHOT 

Generate actions without explicit planning.

TREE_OF_THOUGHT 

Generate multiple reasoning paths.

PLAN_AND_EXECUTE 

Generate a plan then execute it.

REFLEXION 

Reflect on past steps for improvement.

REACT 

Reasoning and acting.

Examples
autonomous_agent_example.cpp.

◆ State

enum class agents::Agent::State
stronginherited

Agent execution state.

Enumerator
READY 

Ready to start execution.

RUNNING 

Currently executing.

WAITING 

Waiting for human input.

COMPLETED 

Execution completed successfully.

FAILED 

Execution failed.

STOPPED 

Execution stopped by user.

Constructor & Destructor Documentation

◆ VoiceAgent()

agents::VoiceAgent::VoiceAgent ( std::shared_ptr< Context > context,
const VoiceConfig & config )

Constructor.

Parameters
contextThe agent context
configThe voice configuration

Member Function Documentation

◆ executeStep()

Task< Step > agents::AutonomousAgent::executeStep ( std::string & step_description,
JsonObject & context )
protectedinherited

Execute a step using coroutines.

Parameters
step_descriptionThe description of the step
contextThe context
Returns
The result of the step

◆ executeTask()

Task< JsonObject > agents::AutonomousAgent::executeTask ( const std::string & task)
protectedinherited

Execute the agent's task using coroutines.

Parameters
taskThe task to execute
Returns
The result of the task

◆ getContext()

std::shared_ptr< Context > agents::Agent::getContext ( ) const
inherited

Get the agent's context.

Returns
The agent context

◆ getOptions()

const Options & agents::Agent::getOptions ( ) const
inherited

Get execution options.

Returns
The execution options

◆ getState()

State agents::Agent::getState ( ) const
inherited

Get the agent's current state.

Returns
The agent state

◆ getSteps()

std::vector< Step > agents::AutonomousAgent::getSteps ( ) const
inherited

Get the steps executed so far.

Returns
The steps executed so far

◆ getToolDescriptions()

std::string agents::AutonomousAgent::getToolDescriptions ( ) const
protectedinherited

Get tool descriptions for prompts.

Returns
The tool descriptions

◆ init()

void agents::VoiceAgent::init ( )
overridevirtual

Initialize the agent.

Reimplemented from agents::AutonomousAgent.

◆ planAndExecute()

Task< JsonObject > agents::AutonomousAgent::planAndExecute ( const std::string & task)
protectedinherited

Plan and execute.

Parameters
taskThe task to plan
Returns
The plan

◆ planReact()

Task< JsonObject > agents::AutonomousAgent::planReact ( const std::string & task)
protectedinherited

Plan using React.

Parameters
taskThe task to plan
Returns
The plan

◆ planReflexion()

Task< JsonObject > agents::AutonomousAgent::planReflexion ( const std::string & task)
protectedinherited

Plan using Reflexion.

Parameters
taskThe task to plan
Returns
The plan

◆ planTreeOfThought()

Task< JsonObject > agents::AutonomousAgent::planTreeOfThought ( const std::string & task)
protectedinherited

Plan using Tree of Thought.

Parameters
taskThe task to plan
Returns
The plan

◆ planZeroShot()

Task< JsonObject > agents::AutonomousAgent::planZeroShot ( const std::string & task)
protectedinherited

Plan using Zero Shot.

Parameters
taskThe task to plan
Returns
The plan

◆ provideFeedback()

void agents::AutonomousAgent::provideFeedback ( const std::string & feedback)
overridevirtualinherited

Provide human feedback.

Parameters
feedbackThe feedback

Reimplemented from agents::Agent.

◆ recordStep()

void agents::AutonomousAgent::recordStep ( const Step & step)
protectedinherited

Record a completed step.

Parameters
stepThe step to record

◆ run()

Task< JsonObject > agents::AutonomousAgent::run ( const std::string & task)
overridevirtualinherited

Run the agent with a task using coroutines.

Parameters
taskThe task to run
Returns
The result of the task

Implements agents::Agent.

◆ runAsync()

void agents::AutonomousAgent::runAsync ( const std::string & task,
std::function< void(const JsonObject &)> callback )
overridevirtualinherited

Run the agent with a callback.

Parameters
taskThe task to run
callbackThe callback for incremental updates

Reimplemented from agents::Agent.

◆ setAgentPrompt()

void agents::AutonomousAgent::setAgentPrompt ( const std::string & agent_prompt)
inherited

Set the agent prompt.

Parameters
agent_promptThe agent prompt

◆ setOptions()

void agents::Agent::setOptions ( const Options & options)
inherited

Set execution options.

Parameters
optionsThe execution options

◆ setPlanningStrategy()

void agents::AutonomousAgent::setPlanningStrategy ( PlanningStrategy strategy)
inherited

Set the planning strategy.

Parameters
strategyThe planning strategy

◆ setStatusCallback()

void agents::Agent::setStatusCallback ( std::function< void(const std::string &)> callback)
inherited

Set a callback for status updates.

Parameters
callbackThe callback to set
Examples
simple_agent.cpp.

◆ setStepCallback()

void agents::AutonomousAgent::setStepCallback ( std::function< void(const Step &)> callback)
inherited

Set a callback for when a step is completed.

Parameters
callbackThe callback

◆ stop()

void agents::AutonomousAgent::stop ( )
overridevirtualinherited

Stop the agent.

Reimplemented from agents::Agent.

◆ waitForFeedback()

Task< std::string > agents::AutonomousAgent::waitForFeedback ( const std::string & message,
const JsonObject & context )
overridevirtualinherited

Wait for feedback using coroutines.

Parameters
messageThe message to wait for feedback
contextThe context
Returns
The feedback

Reimplemented from agents::Agent.