Empower agents to take actions during conversations.
ChatGPTAgent
.BaseAction
class.
The BaseAction
class has the following key structure:
ActionsWorker
: how actions are executed and consumedActionsWorker
class plays a crucial role in the async processing of actions within the system. It’s a specialized form of the InterruptibleWorker
class,
designed to handle the execution of actions and passing results back to the agent.
The ActionsWorker
is initialized with an input queue and an output queue. It uses an ActionFactory
instance to create and execute actions based on the inputs it receives.
The flow of actions is as follows:
ActionsWorker
through the worker’s input queue.ActionsWorker
reads the action request from the input queue. It then creates an instance of the appropriate action using the ActionFactory
, and executes it using the provided parameters.ActionOutput
object which encapsulates the result of the action.ActionsWorker
creates an ActionResultAgentInput
from the ActionOutput
, and puts it in its output queue.ActionResultAgentInput
from the queue in its process method. This
result is added to the transcript of the conversation, and can influence the behavior of the agent in subsequent interactions.NylasSendEmail
, which extends the BaseAction
class. It implements the run method to send an email using the Nylas API.
We will also show how to add this action to an agent and use it in a conversation.
action_type
(but doesn’t have any other specific parameters). We also add an _end_of_run_hook()
, which we customized to log that the action successfully completed.
ActionFactory
ActionFactory
that can produce instances of the action.
We will store the code above in nylas_send_email.py
and make a factory that can create this action for an agent: