-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Problem
LM and DummyLM are structurally separate types with duplicated APIs:
- Both have
call(),inspect_history(),cache_handler,temperature,max_tokens - But they don't share a trait — code that wants to be generic over "any LM" can't be
DSPy Python has BaseLM as the abstract base class that both real and mock implementations extend.
Proposal
Extract a shared trait:
#[async_trait]
pub trait LanguageModel: Send + Sync {
async fn call(&self, messages: Chat, tools: Vec<Arc<dyn ToolDyn>>) -> Result<LMResponse>;
async fn inspect_history(&self, n: usize) -> Vec<HistoryEntry>;
fn model(&self) -> &str;
}LM and DummyLM both impl this. GLOBAL_SETTINGS stores Arc<dyn LanguageModel>. Modules reference the trait, not the concrete type.
Related
- LM layer: per-module LM, config merging, retry/backoff #69 (LM layer: per-module LM)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels