mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-31 11:29:30 +00:00
49 lines
942 B
Rust
49 lines
942 B
Rust
use serde::{Deserialize, Serialize};
|
|
use std::option::Option;
|
|
|
|
use crate::impl_builder_methods;
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct EmbeddingData {
|
|
pub object: String,
|
|
pub embedding: Vec<f32>,
|
|
pub index: i32,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Clone)]
|
|
pub struct EmbeddingRequest {
|
|
pub model: String,
|
|
pub input: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub user: Option<String>,
|
|
}
|
|
|
|
impl EmbeddingRequest {
|
|
pub fn new(model: String, input: String) -> Self {
|
|
Self {
|
|
model,
|
|
input,
|
|
user: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl_builder_methods!(
|
|
EmbeddingRequest,
|
|
user: String
|
|
);
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct EmbeddingResponse {
|
|
pub object: String,
|
|
pub data: Vec<EmbeddingData>,
|
|
pub model: String,
|
|
pub usage: Usage,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct Usage {
|
|
pub prompt_tokens: i32,
|
|
pub total_tokens: i32,
|
|
}
|