pub struct AgentContext(/* private fields */);Expand description
AI Agent conversation context.
Reference: https://open.longbridge.com/en/docs/ai/chat/conversation
Implementations§
Source§impl AgentContext
impl AgentContext
Sourcepub fn new(config: Arc<Config>) -> Self
pub fn new(config: Arc<Config>) -> Self
Create an AgentContext
Sourcepub fn log_subscriber(&self) -> Arc<dyn Subscriber + Send + Sync>
pub fn log_subscriber(&self) -> Arc<dyn Subscriber + Send + Sync>
Returns the log subscriber
Sourcepub async fn workspaces(&self) -> Result<WorkspacesResponse>
pub async fn workspaces(&self) -> Result<WorkspacesResponse>
List the Workspaces the current account belongs to.
Path: GET /v1/ai/workspaces
Sourcepub async fn agents(
&self,
workspace_id: impl Into<String>,
opts: impl Into<Option<GetAgentsOptions>>,
) -> Result<AgentsResponse>
pub async fn agents( &self, workspace_id: impl Into<String>, opts: impl Into<Option<GetAgentsOptions>>, ) -> Result<AgentsResponse>
List the Agents in the specified Workspace.
Path: GET /v1/ai/workspaces/{id}/agents
Sourcepub async fn public_agents(
&self,
opts: impl Into<Option<GetAgentsOptions>>,
) -> Result<AgentsResponse>
pub async fn public_agents( &self, opts: impl Into<Option<GetAgentsOptions>>, ) -> Result<AgentsResponse>
List all publicly available Agents on the platform — the same catalog shown on the Explore page.
Unlike agents, this endpoint is not scoped to a
Workspace: it returns every Agent that is published and publicly shared.
The returned Agent::uid is used as the path parameter of
conversation.
Path: GET /v1/ai/agents
Sourcepub async fn conversation(
&self,
agent_id: impl Into<String>,
query: impl Into<String>,
chat_uid: impl Into<Option<String>>,
parent_message_id: impl Into<Option<String>>,
) -> Result<ConversationResponse>
pub async fn conversation( &self, agent_id: impl Into<String>, query: impl Into<String>, chat_uid: impl Into<Option<String>>, parent_message_id: impl Into<Option<String>>, ) -> Result<ConversationResponse>
Start a conversation with the specified Agent, blocking until the run succeeds, is interrupted, or fails.
parent_message_id is the message_id from a previous response. Pass
it when asking a follow-up in an existing conversation to attach the new
message after the specified one, keeping the message stream in order. It
is only valid together with chat_uid, the parent message must belong
to that conversation, and it must not be set for a new conversation.
Path: POST /v1/ai/agents/{id}/conversations
Sourcepub async fn continue_conversation(
&self,
agent_id: impl Into<String>,
chat_uid: impl Into<String>,
message_id: impl Into<String>,
answers: AnswersByToolCall,
) -> Result<ConversationResponse>
pub async fn continue_conversation( &self, agent_id: impl Into<String>, chat_uid: impl Into<String>, message_id: impl Into<String>, answers: AnswersByToolCall, ) -> Result<ConversationResponse>
Resume an interrupted conversation, blocking until the run succeeds, is interrupted again, or fails.
Path: POST /v1/ai/agents/{id}/conversations/{chat_uid}/messages/{message_id}/ continue
Sourcepub async fn conversation_streamed(
&self,
agent_id: impl Into<String>,
query: impl Into<String>,
chat_uid: impl Into<Option<String>>,
parent_message_id: impl Into<Option<String>>,
) -> Result<impl Stream<Item = Result<ConversationStreamEvent>> + Send + 'static>
pub async fn conversation_streamed( &self, agent_id: impl Into<String>, query: impl Into<String>, chat_uid: impl Into<Option<String>>, parent_message_id: impl Into<Option<String>>, ) -> Result<impl Stream<Item = Result<ConversationStreamEvent>> + Send + 'static>
Start a conversation with the specified Agent, returning a [Stream] of
run-progress events over SSE. The run’s outcome is carried by a
ConversationStreamEvent::WorkflowFinished event (succeeded, failed,
or stopped) or, if the Agent needs more input from you, a
ConversationStreamEvent::HumanInteractionRequired event instead —
an interrupted run never emits WorkflowFinished. Neither is
necessarily the last item — the server may still emit a few more
housekeeping events (e.g.
ConversationStreamEvent::ChatTitleUpdated) before actually closing
the connection, so keep draining the stream until it ends rather than
stopping as soon as you see one.
parent_message_id behaves as in Self::conversation.
Path: POST /v1/ai/agents/{id}/conversations (Accept: text/event-stream)
Sourcepub async fn continue_conversation_streamed(
&self,
agent_id: impl Into<String>,
chat_uid: impl Into<String>,
message_id: impl Into<String>,
answers: AnswersByToolCall,
) -> Result<impl Stream<Item = Result<ConversationStreamEvent>> + Send + 'static>
pub async fn continue_conversation_streamed( &self, agent_id: impl Into<String>, chat_uid: impl Into<String>, message_id: impl Into<String>, answers: AnswersByToolCall, ) -> Result<impl Stream<Item = Result<ConversationStreamEvent>> + Send + 'static>
Resume an interrupted conversation, returning a [Stream] of
run-progress events over SSE.
Path: POST /v1/ai/agents/{id}/conversations/{chat_uid}/messages/{message_id}/ continue (Accept: text/event-stream)
Trait Implementations§
Source§impl Clone for AgentContext
impl Clone for AgentContext
Source§fn clone(&self) -> AgentContext
fn clone(&self) -> AgentContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AgentContext
impl !RefUnwindSafe for AgentContext
impl Send for AgentContext
impl Sync for AgentContext
impl Unpin for AgentContext
impl UnsafeUnpin for AgentContext
impl !UnwindSafe for AgentContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more