pub struct DeepseekAgent { /* private fields */ }Expand description
DeepseekAgent: encapsulates a conversation (Conversation) and a collection of tools.
Responsible for coordinating API calls and executing tools as requested by the model.
Fields use pub(crate) visibility so the sibling stream submodule can access internal
state (for example tools and tool_index).
Implementations§
Source§impl DeepseekAgent
impl DeepseekAgent
Sourcepub fn new(token: impl Into<String>) -> Self
pub fn new(token: impl Into<String>) -> Self
Create an Agent using the provided token.
This internally constructs an ApiClient and attaches a DeepseekConversation.
Sourcepub fn add_tool<TT: Tool + 'static>(self, tool: TT) -> Self
pub fn add_tool<TT: Tool + 'static>(self, tool: TT) -> Self
Add a tool (supports method chaining).
Registers the tool and indexes its raw (protocol) function names so incoming tool call requests can be routed to the correct implementation.
Sourcepub fn chat(self, user_message: &str) -> AgentStream
pub fn chat(self, user_message: &str) -> AgentStream
Push a user message into the conversation and return an AgentStream.
The returned AgentStream drives the API request and any subsequent tool execution.
The return type uses a fully-qualified path and depends on the sibling stream
submodule providing AgentStream.
Sourcepub fn with_streaming(self) -> Self
pub fn with_streaming(self) -> Self
Enable streaming text output for each API turn.
When set, the agent uses send_stream internally so text fragments are
yielded to the caller as they arrive instead of waiting for a full response.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Set a custom system prompt to inject at the start of the conversation.
Builder-style: returns self so the call can be chained.
Sourcepub fn with_summarizer(self, summarizer: impl Summarizer + 'static) -> Self
pub fn with_summarizer(self, summarizer: impl Summarizer + 'static) -> Self
Set a summarizer to use for conversation summarization.
Builder-style: returns self so the call can be chained.