Agent

The Agent is an object that contains all of your agent’s functionality. Must be assigned to a variable named agent.

Example Usage

agent = Agent(
    id="agent-id-1234",
    configure_session=configure_session,
    llm_response_handler=llm_response_handler,
)

Fields

id
string
required

The ID of your agent. You can retrieve it from Jay’s dashboard. This field can be shared publicly.

configure_session
function
required

An asynchronous function that’s that runs at the beginning of every session. For details, see the Configure Session reference.

llm_response_handler
function
required

An asynchronous function that’s that’s responsible for returning the LLM’s response. For details, see the LLM Response Handler reference.

tools
array (Optional)

A list of “tools” (i.e. function calls) that your LLM can invoke to connect to external data and systems. Each item in this array is an asynchronous function. For details, see the Function Calling guide.

on_user_started_speaking
function (Optional)

An asynchronous function that’s called when the user starts speaking. For details, see the Event Handlers reference.

on_user_stopped_speaking
function (Optional)

An asynchronous function that’s called when the user stops speaking. For details, see the Event Handlers reference.

on_agent_started_speaking
function (Optional)

An asynchronous function that’s called when the agent begins speaking. For details, see the Event Handlers reference.

on_agent_stopped_speaking
function (Optional)

An asynchronous function that’s called when the agent finishes speaking. For details, see the Event Handlers reference.

on_user_message_added
function (Optional)

An asynchronous function that’s called when the user’s message is added to the chat history during the session. For details, see the Event Handlers reference.

on_agent_message_added
function (Optional)

An asynchronous function that’s called when the agent’s message is added to the chat history during the session. For details, see the Event Handlers reference.

on_agent_interrupted
function (Optional)

An asynchronous function that’s called if the agent is interrupted by the user while speaking. For details, see the Event Handlers reference.

on_function_calls_collected
function (Optional)

An asynchronous function that’s called when Jay receives the complete set of functions to execute from the LLM. For details, see the Event Handlers reference.

on_function_calls_executed
function (Optional)

An asynchronous function that’s called after Jay has executed all the functions the model requested. For details, see the Event Handlers reference.