use serde::{Deserialize, Serialize};
pub mod wire;
pub use crate::client::voyageai::VoyageAi;
pub use wire::{Embeddings, Rerank, VoyageAiConfig};
const VOYAGEAI_API_BASE_URL: &str = "https://api.voyageai.com/v1";
pub const VOYAGE_3_LARGE: &str = "voyage-3-large";
pub const VOYAGE_3_5: &str = "voyage-3.5";
pub const VOYAGE_3_5_LITE: &str = "voyage.3-5.lite";
pub const VOYAGE_CODE_3: &str = "voyage-code-3";
pub const VOYAGE_FINANCE_2: &str = "voyage-finance-2";
pub const VOYAGE_LAW_2: &str = "voyage-law-2";
pub const VOYAGE_CODE_2: &str = "voyage-code-2";
pub fn model_dimensions_from_identifier(model_identifier: &str) -> Option<usize> {
match model_identifier {
"voyage-code-2" => Some(1536),
"voyage-3-large" | "voyage-3.5" | "voyage.3-5.lite" | "voyage-code-3"
| "voyage-finance-2" | "voyage-law-2" => Some(1024),
_ => None,
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmbeddingResponse {
pub object: String,
pub data: Vec<EmbeddingData>,
pub model: String,
pub usage: Usage,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Usage {
pub total_tokens: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmbeddingData {
pub object: String,
pub embedding: Vec<f64>,
pub index: usize,
}
pub const RERANK_2_5: &str = "rerank-2.5";
pub const RERANK_2_5_LITE: &str = "rerank-2.5-lite";
pub const RERANK_2: &str = "rerank-2";
pub const RERANK_2_LITE: &str = "rerank-2-lite";
pub const RERANK_1: &str = "rerank-1";
pub const RERANK_LITE_1: &str = "rerank-lite-1";
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RerankApiResponse {
pub data: Vec<RerankApiData>,
pub model: String,
pub usage: RerankApiUsage,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RerankApiUsage {
pub total_tokens: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RerankApiData {
pub index: usize,
pub relevance_score: f64,
#[serde(default)]
pub document: Option<String>,
}