pub struct HttpAgent { /* private fields */ }Expand description
An HTTP endpoint and reusable connection settings. Create independent local
conversations with HttpAgent::thread, or consume typed events with
run_events.
Implementations§
Source§impl HttpAgent
impl HttpAgent
Sourcepub fn new(url: impl AsRef<str>) -> Result<Self>
pub fn new(url: impl AsRef<str>) -> Result<Self>
Connect to url using default settings. No request is made yet.
Sourcepub fn from_transport(transport: HttpTransport) -> Self
pub fn from_transport(transport: HttpTransport) -> Self
Use a caller-configured HTTP transport.
Sourcepub fn builder(url: impl AsRef<str>) -> HttpAgentBuilder
pub fn builder(url: impl AsRef<str>) -> HttpAgentBuilder
Configure headers, timeouts and the underlying HTTP client.
Sourcepub fn thread(&self, id: impl Into<ThreadId>) -> Thread<HttpTransport>
pub fn thread(&self, id: impl Into<ThreadId>) -> Thread<HttpTransport>
An independent local conversation. This does not retrieve remote history.
Sourcepub fn thread_with_state<S: Serialize + DeserializeOwned>(
&self,
id: impl Into<ThreadId>,
state: S,
) -> Result<Thread<HttpTransport, S>>
pub fn thread_with_state<S: Serialize + DeserializeOwned>( &self, id: impl Into<ThreadId>, state: S, ) -> Result<Thread<HttpTransport, S>>
Initialize a typed conversation using a serializable state value.
Sourcepub fn thread_builder<S>(
&self,
id: impl Into<ThreadId>,
) -> ThreadBuilder<HttpTransport, S>
pub fn thread_builder<S>( &self, id: impl Into<ThreadId>, ) -> ThreadBuilder<HttpTransport, S>
Configure initial history, state, tools, diagnostics and verification.
Sourcepub fn restore_thread(
&self,
snapshot: ThreadSnapshot,
) -> Result<Thread<HttpTransport>>
pub fn restore_thread( &self, snapshot: ThreadSnapshot, ) -> Result<Thread<HttpTransport>>
Restore a saved local JSON conversation with this endpoint’s transport.
Sourcepub fn restore_thread_with_state<S: DeserializeOwned>(
&self,
snapshot: ThreadSnapshot,
) -> Result<Thread<HttpTransport, S>>
pub fn restore_thread_with_state<S: DeserializeOwned>( &self, snapshot: ThreadSnapshot, ) -> Result<Thread<HttpTransport, S>>
Restore and validate the current raw state against S.
Sourcepub fn run_events(&self, params: impl Into<RunAgentInput>) -> EventStream
pub fn run_events(&self, params: impl Into<RunAgentInput>) -> EventStream
Typed events after compatibility translation and schema enforcement.
Chunks are not assembled or applied to conversation state here. Use
Transport::run and TransportStream::into_json to inspect the
original wire JSON.
Sourcepub fn transport(&self) -> &HttpTransport
pub fn transport(&self) -> &HttpTransport
Underlying transport settings.