configure_session
function, which is called at the beginning of
every session. It’s where you set fields such as your speech-to-text provider, initial messages,
etc. Here’s a simple example:
configure_session
function, you can specify arbitrary fields that will be available throughout a
session, which is particularly useful if your LLM logic needs access to user-specific fields, like a
user ID. Here’s how you can make a my_user_id
field available throughout a session:
configure_session
function can also accept custom fields sent from wherever you start the
session. For example, here’s how you can pass in a my_user_timezone
field:
configure_session
function, see the Configuring
Sessions reference.
llm_response_handler
function is responsible for returning the LLM’s response during a
session. It’s called every time a response is expected from the agent.
Here’s an example:
llm_response_handler
, you can truncate the chat history, call a RAG pipeline, use any
LLM provider, or add any other logic that controls the LLM’s response.
The llm_response_handler
can accept the custom fields that you define when configuring the
session. For example, if you specified a user ID field called my_user_id
when configuring the
session, you can access it like this in your llm_response_handler
:
Agent
Agent
is an object that contains all of your agent’s functionality.
The Agent
below is the simplest possible agent. It contains the two functions defined above
(configure_session
and llm_response_handler
). It also contains your agent ID, which was
automatically added to the agent in the Quickstart guide.
Agent
is also where you’ll define event handlers and function calls (i.e. tool calls), which
are covered in other guides.
For a complete list of fields on the Agent
, see the Agent
reference.
Note: All of the logic related to your agent, including utility functions, must go in an
agent
folder. This is required because Jay packages this logic into a container that we host
when you deploy your agent.