Files
archy/core/archipelago/src/assistant/backends/mod.rs
T

41 lines
1.2 KiB
Rust
Raw Normal View History

//! The `Backend` trait — the wire-format-agnostic seam every model backend
//! (Ollama, Claude, Routstr) implements once. The loop and every tool are
//! written against this trait only; wire-format differences live entirely
//! inside each adapter.
use std::path::Path;
use anyhow::Result;
use async_trait::async_trait;
use super::tools::{ChatMessage, ToolCall, ToolDef};
pub mod claude;
#[cfg(test)]
pub mod scripted;
pub enum BackendTurn {
Text(String),
ToolCalls(Vec<ToolCall>),
}
#[async_trait]
pub trait Backend: Send + Sync {
async fn send(
&self,
system: &str,
tools: &[ToolDef],
history: &[ChatMessage],
) -> Result<BackendTurn>;
}
/// D-04's backend chain: local Ollama first (node data never leaves the
/// node when a local model is available), then Claude, then Routstr. Only
/// the Claude leg is implemented in this tracer — `backends/ollama.rs`
/// (13-10) and `backends/routstr.rs` (13-13) slot in ahead of and behind it
/// without changing the `Backend` trait; that is the architectural
/// commitment this tracer proves.
pub fn select_backend(data_dir: &Path) -> Box<dyn Backend> {
Box::new(claude::ClaudeBackend::new(data_dir.to_path_buf()))
}