feat: add deepseek provider scaffolding

This commit is contained in:
zyl
2026-03-25 04:24:59 +00:00
parent 1ab0012275
commit 0d0097b003
9 changed files with 1490 additions and 4 deletions

45
src/llm/provider.rs Normal file
View File

@@ -0,0 +1,45 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ChatMessage {
pub role: String,
pub content: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ToolDefinition {
pub name: String,
pub description: String,
pub parameters: Value,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ToolFunctionCall {
pub id: String,
pub name: String,
pub arguments: Value,
}
pub trait LlmProvider {
fn chat(
&self,
messages: &[ChatMessage],
tools: &[ToolDefinition],
) -> Result<Vec<ToolFunctionCall>, LlmError>;
}
#[derive(Debug, Error)]
pub enum LlmError {
#[error(transparent)]
Config(#[from] crate::config::ConfigError),
#[error(transparent)]
Http(#[from] reqwest::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error("llm returned no tool calls")]
NoToolCalls,
#[error("llm returned malformed tool arguments: {0}")]
InvalidToolArguments(String),
}