Add embedding models

This commit is contained in:
Dongri Jin
2024-01-26 11:13:24 +09:00
parent 91987abed7
commit 4e6fbcedd5
3 changed files with 11 additions and 8 deletions

View File

@ -1,14 +1,12 @@
use openai_api_rs::v1::api::Client;
use openai_api_rs::v1::common::TEXT_EMBEDDING_3_SMALL;
use openai_api_rs::v1::embedding::EmbeddingRequest;
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-ada-002".to_string(),
"story time".to_string(),
);
let req = EmbeddingRequest::new(TEXT_EMBEDDING_3_SMALL.to_string(), "story time".to_string());
let result = client.embedding(req)?;
println!("{:?}", result.data);