lc_core/batch/mod.rs
1// src/core/batch/mod.rs
2//! Batch API client for OpenAI and Anthropic batch processing.
3//!
4//! Provides a unified interface for submitting, polling, and retrieving
5//! results from batch API endpoints:
6//!
7//! - **OpenAI Batch API**: POST /v1/batches (JSONL file upload + batch creation)
8//! - **Anthropic Batch API**: POST /v1/messages/batches (inline requests array)
9//!
10//! # Example
11//! ```ignore
12//! use langchainrust::core::batch::{BatchClient, BatchProvider, BatchRequest};
13//! use langchainrust::Message;
14//!
15//! let client = BatchClient::new(BatchProvider::OpenAI, "sk-...");
16//! let requests = vec![
17//! BatchRequest {
18//! custom_id: "req-1".into(),
19//! messages: vec![Message::human("Hello")],
20//! model: "gpt-4o".into(),
21//! temperature: None,
22//! max_tokens: None,
23//! },
24//! ];
25//! // let batch_id = client.submit(requests).await?;
26//! // let results = client.submit_and_wait(requests, 5000, 300_000).await?;
27//! ```
28
29mod client;
30#[cfg(test)]
31mod tests;
32mod types;
33
34pub use client::BatchClient;
35pub use types::{BatchError, BatchId, BatchProvider, BatchRequest, BatchResult, BatchStatus};