dspy_rs/adapter/
mod.rs

1pub mod chat;
2
3pub use chat::*;
4
5use crate::{Chat, Example, LM, Message, MetaSignature, Prediction};
6use anyhow::Result;
7use async_trait::async_trait;
8use serde_json::Value;
9use std::collections::HashMap;
10use std::sync::Arc;
11
12#[async_trait]
13pub trait Adapter: Send + Sync + 'static {
14    fn format(&self, signature: &dyn MetaSignature, inputs: Example) -> Chat;
15    fn parse_response(
16        &self,
17        signature: &dyn MetaSignature,
18        response: Message,
19    ) -> HashMap<String, Value>;
20    async fn call(
21        &self,
22        lm: Arc<LM>,
23        signature: &dyn MetaSignature,
24        inputs: Example,
25    ) -> Result<Prediction>;
26}