Module

Trait Module 

Source
pub trait Module: Send + Sync {
    // Required method
    async fn forward(&self, inputs: Example) -> Result<Prediction>;

    // Provided method
    async fn batch(
        &self,
        inputs: Vec<Example>,
        max_concurrency: usize,
        display_progress: bool,
    ) -> Result<Vec<Prediction>> { ... }
}

Required Methods§

Source

async fn forward(&self, inputs: Example) -> Result<Prediction>

Provided Methods§

Source

async fn batch( &self, inputs: Vec<Example>, max_concurrency: usize, display_progress: bool, ) -> Result<Vec<Prediction>>

Examples found in repository?
examples/06-other-providers-batch.rs (line 101)
77async fn main() {
78    // Anthropic
79    configure(
80        LM::builder()
81            .model("anthropic:claude-sonnet-4-5-20250929".to_string())
82            .build()
83            .await
84            .unwrap(),
85        ChatAdapter,
86    );
87
88    let example = vec![
89        example! {
90            "question": "input" => "What is the capital of France?",
91        },
92        example! {
93            "question": "input" => "What is the capital of Germany?",
94        },
95        example! {
96            "question": "input" => "What is the capital of Italy?",
97        },
98    ];
99
100    let qa_rater = QARater::builder().build();
101    let prediction = qa_rater.batch(example.clone(), 2, true).await.unwrap();
102    println!("Anthropic: {prediction:?}");
103
104    // Gemini
105    configure(
106        LM::builder()
107            .model("gemini:gemini-2.0-flash".to_string())
108            .build()
109            .await
110            .unwrap(),
111        ChatAdapter,
112    );
113
114    let prediction = qa_rater.batch(example, 2, true).await.unwrap();
115    println!("Gemini: {prediction:?}");
116}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§