lib/adapters/
llm.rs

1use reqwest::header::HeaderMap;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4use crate::utils::llm::FromLLMResponse;
5use anyhow::Result;
6use std::path::PathBuf;
7
8#[derive(Serialize, Deserialize, Debug)]
9pub enum OutputFormat {
10    String,
11    Json,
12    StrictJson(Value),
13}
14
15pub trait LLMProvider: LLMInterface {
16    fn generate_headers(&self) -> Result<HeaderMap>;
17    fn generate_request_body(
18        &self,
19        sys_prompt: &str,
20        user_prompt: &str,
21        output_format: &OutputFormat,
22    ) -> Result<Value>;
23
24}
25
26pub trait LLMInterface {
27    fn send_request<T: FromLLMResponse + Send + Sync>(
28        &self,
29        sys_prompt: &str,
30        user_prompt: &str
31    ) -> impl std::future::Future<Output = Result<T>>;
32
33    fn upload_file(&self, file_path: PathBuf) -> impl std::future::Future<Output = Result<Value>>;
34
35    fn create_fine_tuning_job(&self, training_file: &str) -> impl std::future::Future<Output = Result<Value>>;
36
37    fn train(&self, file_path: PathBuf) -> impl std::future::Future<Output = Result<()>>;
38}
39
40