chore: make some stuff in embeddings less stringly typed
This commit is contained in:
@@ -46,6 +46,14 @@ pub struct CreateEmbeddingRequest<Model> {
|
|||||||
pub user: Option<String>,
|
pub user: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Embedding object type
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum EmbeddingObject {
|
||||||
|
/// Embedding
|
||||||
|
Embedding,
|
||||||
|
}
|
||||||
|
|
||||||
/// Represents a single embedding in the response
|
/// Represents a single embedding in the response
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct Embedding {
|
pub struct Embedding {
|
||||||
@@ -57,7 +65,7 @@ pub struct Embedding {
|
|||||||
pub index: u32,
|
pub index: u32,
|
||||||
|
|
||||||
/// The object type, which is always "embedding"
|
/// The object type, which is always "embedding"
|
||||||
pub object: String,
|
pub object: EmbeddingObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the possible output formats for embeddings
|
/// Represents the possible output formats for embeddings
|
||||||
@@ -80,17 +88,25 @@ pub struct Usage {
|
|||||||
pub total_tokens: u32,
|
pub total_tokens: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// List object type
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum ListObject {
|
||||||
|
/// List
|
||||||
|
List,
|
||||||
|
}
|
||||||
|
|
||||||
/// Response from the embeddings API
|
/// Response from the embeddings API
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct CreateEmbeddingResponse {
|
pub struct CreateEmbeddingResponse<Model> {
|
||||||
/// List of generated embeddings
|
/// List of generated embeddings
|
||||||
pub data: Vec<Embedding>,
|
pub data: Vec<Embedding>,
|
||||||
|
|
||||||
/// The name of the model used to generate the embeddings
|
/// The name of the model used to generate the embeddings
|
||||||
pub model: String,
|
pub model: Model,
|
||||||
|
|
||||||
/// The object type, which is always "list"
|
/// The object type, which is always "list"
|
||||||
pub object: String,
|
pub object: ListObject,
|
||||||
|
|
||||||
/// Usage information for the request
|
/// Usage information for the request
|
||||||
pub usage: Usage,
|
pub usage: Usage,
|
||||||
|
|||||||
Reference in New Issue
Block a user