pub struct DeepseekAgent { /* private fields */ }Expand description
An agent that combines a Conversation with a set of callable tools.
Build one with the fluent builder methods, then call chat
to start a turn:
use ds_api::{DeepseekAgent, tool};
use serde_json::{Value, json};
struct MyTool;
#[tool]
impl ds_api::Tool for MyTool {
async fn greet(&self, name: String) -> Value {
json!({ "greeting": format!("Hello, {name}!") })
}
}
let agent = DeepseekAgent::new("sk-...")
.add_tool(MyTool);Implementations§
Source§impl DeepseekAgent
impl DeepseekAgent
Sourcepub fn add_tool<TT: Tool + 'static>(self, tool: TT) -> Self
pub fn add_tool<TT: Tool + 'static>(self, tool: TT) -> Self
Register a tool (builder-style, supports chaining).
The tool’s protocol-level function names are indexed so incoming tool-call requests from the model can be dispatched to the correct implementation.
Sourcepub fn chat(self, user_message: &str) -> AgentStream
pub fn chat(self, user_message: &str) -> AgentStream
Push a user message and return an AgentStream
that drives the full agent loop (API calls + tool execution).
Sourcepub fn with_streaming(self) -> Self
pub fn with_streaming(self) -> Self
Enable SSE streaming for each API turn (builder-style).
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Prepend a permanent system prompt to the conversation history (builder-style).
System messages added this way are never removed by the built-in summarizers.
Sourcepub fn with_summarizer(self, summarizer: impl Summarizer + 'static) -> Self
pub fn with_summarizer(self, summarizer: impl Summarizer + 'static) -> Self
Replace the summarizer used for context-window management (builder-style).
Auto Trait Implementations§
impl Freeze for DeepseekAgent
impl !RefUnwindSafe for DeepseekAgent
impl Send for DeepseekAgent
impl Sync for DeepseekAgent
impl Unpin for DeepseekAgent
impl UnsafeUnpin for DeepseekAgent
impl !UnwindSafe for DeepseekAgent
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
Mutably borrows from an owned value. Read more