AgentSession
AgentSession.RdRepresents a Synapse Agent Session
Usage
AgentSession(id=NULL, access_level="PUBLICLY_ACCESSIBLE", started_on=NULL, started_by=NULL, modified_on=NULL, agent_registration_id=NULL, etag=NULL, chat_history=list())Arguments
- id
(Optional[str]) The unique ID of the agent session. Can only be used by the user that created it.
- access_level
(Optional[AgentSessionAccessLevel]) The access level of the agent session. One of PUBLICLY_ACCESSIBLE, READ_YOUR_PRIVATE_DATA, or WRITE_YOUR_PRIVATE_DATA.
- started_on
(Optional[datetime]) The date the agent session was started.
- started_by
(Optional[int]) The ID of the user who started the agent session.
- modified_on
(Optional[datetime]) The date the agent session was last modified.
- agent_registration_id
(Optional[int]) The registration ID of the agent that will be used for this session.
- etag
(Optional[str]) The etag of the agent session.
- chat_history
(List[AgentPrompt]) A list of AgentPrompt objects.
Methods
AgentSession(id=NULL, access_level="PUBLICLY_ACCESSIBLE", started_on=NULL, started_by=NULL, modified_on=NULL, agent_registration_id=NULL, etag=NULL, chat_history=list()): Constructor forAgentSessionsynPrompt(instance, prompt, enable_trace=FALSE, print_response=FALSE, newer_than=NULL, timeout=120L, synapse_client=NULL): Sends a prompt to the agent and adds the response to the AgentSession's chat history. A session must be started before sending a prompt.synStart(instance, synapse_client=NULL): Starts an agent session.synUpdate(instance, synapse_client=NULL): Updates an agent session. Only updates to the access level are currently supported.
Note
It is recommended to use the Agent class to conduct chat sessions,
but you are free to use AgentSession directly if you wish.
Examples
if (FALSE) { # \dontrun{
## Example 1: Start a session and send a prompt.
# Start a session with a custom agent by providing the agent's registration ID
# and calling synStart(). Then, send a prompt to the agent.
library(synapser)
synLogin()
my_session = AgentSession(agent_registration_id = "foo") |> synStart()
my_session |> synPrompt(
prompt = "Hello",
enable_trace = TRUE,
print_response = TRUE
)
## Example 2: Prompt an existing session.
# If you already have an existing session, you can send it a prompt by
# constructing an AgentSession with its session ID.
library(synapser)
synLogin()
my_session = AgentSession(id = "foo")
my_session |> synPrompt(
prompt = "Hello",
enable_trace = TRUE,
print_response = TRUE
)
## Example 3: Update the access level of an existing session.
# Construct an AgentSession with its session ID, set the access level you
# want, and call synUpdate().
library(synapser)
synLogin()
my_session = AgentSession(id = "foo")
my_session$access_level = "READ_YOUR_PRIVATE_DATA"
my_session = my_session |> synUpdate()
## Example 4: Get an existing session.
# Retrieve an existing session by its session ID.
library(synapser)
synLogin()
my_session = AgentSession(id = "foo") |> synGet()
print(my_session$access_level)
} # }