36 lines
905 B
Rust
36 lines
905 B
Rust
// nazarick-core/src/llm/traits.rs
|
|
|
|
use std::str::FromStr;
|
|
use crate::types::Result;
|
|
use crate::llm::types::{LlmRequest, LlmResponse};
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum SkillFormat {
|
|
/// XML-Tags — für lokale Modelle ohne Function Calling
|
|
Xml,
|
|
/// Native Tool Use — Ollama, Mistral API, OpenRouter
|
|
ToolUse,
|
|
/// Skills deaktiviert
|
|
None,
|
|
}
|
|
|
|
impl FromStr for SkillFormat {
|
|
type Err = ();
|
|
|
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
|
match s {
|
|
"tool_use" => Ok(Self::ToolUse),
|
|
"none" => Ok(Self::None),
|
|
_ => Ok(Self::Xml),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
pub trait LlmProvider: Send + Sync {
|
|
async fn complete(&self, request: LlmRequest) -> Result<LlmResponse>;
|
|
fn name(&self) -> &str;
|
|
fn skill_format(&self) -> SkillFormat {
|
|
SkillFormat::Xml
|
|
}
|
|
} |