Skip to content

Commit

Permalink
Merge pull request #74 from dongri/add-dimensions
Browse files Browse the repository at this point in the history
Add dimensions parameter
  • Loading branch information
Dongri Jin committed Jan 28, 2024
2 parents 2e334e7 + f1685c9 commit 11f43f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/embedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());

let req = EmbeddingRequest::new(TEXT_EMBEDDING_3_SMALL.to_string(), "story time".to_string());
let mut req =
EmbeddingRequest::new(TEXT_EMBEDDING_3_SMALL.to_string(), "story time".to_string());
req.dimensions = Some(10);

let result = client.embedding(req)?;
println!("{:?}", result.data);
Expand Down
3 changes: 3 additions & 0 deletions src/v1/embedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub struct EmbeddingRequest {
pub model: String,
pub input: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub dimensions: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<String>,
}

Expand All @@ -23,6 +25,7 @@ impl EmbeddingRequest {
Self {
model,
input,
dimensions: None,
user: None,
}
}
Expand Down

0 comments on commit 11f43f8

Please sign in to comment.