File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ use std::env;
77async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
88 let client = OpenAIClient :: new ( env:: var ( "OPENAI_API_KEY" ) . unwrap ( ) . to_string ( ) ) ;
99
10- let mut req =
11- EmbeddingRequest :: new ( TEXT_EMBEDDING_3_SMALL . to_string ( ) , "story time" . to_string ( ) ) ;
10+ let mut req = EmbeddingRequest :: new (
11+ TEXT_EMBEDDING_3_SMALL . to_string ( ) ,
12+ vec ! [ "story time" . to_string( ) , "Once upon a time" . to_string( ) ] ,
13+ ) ;
1214 req. dimensions = Some ( 10 ) ;
1315
1416 let result = client. embedding ( req) . await ?;
Original file line number Diff line number Diff line change @@ -11,21 +11,30 @@ pub struct EmbeddingData {
1111 pub index : i32 ,
1212}
1313
14+ #[ derive( Debug , Serialize , Deserialize , Clone ) ]
15+ #[ serde( rename_all = "lowercase" ) ]
16+ pub enum EncodingFormat {
17+ Float ,
18+ Base64 ,
19+ }
20+
1421#[ derive( Debug , Serialize , Clone , Deserialize ) ]
1522pub struct EmbeddingRequest {
1623 pub model : String ,
17- pub input : String ,
24+ pub input : Vec < String > ,
25+ pub encoding_format : Option < EncodingFormat > ,
1826 #[ serde( skip_serializing_if = "Option::is_none" ) ]
1927 pub dimensions : Option < i32 > ,
2028 #[ serde( skip_serializing_if = "Option::is_none" ) ]
2129 pub user : Option < String > ,
2230}
2331
2432impl EmbeddingRequest {
25- pub fn new ( model : String , input : String ) -> Self {
33+ pub fn new ( model : String , input : Vec < String > ) -> Self {
2634 Self {
2735 model,
2836 input,
37+ encoding_format : None ,
2938 dimensions : None ,
3039 user : None ,
3140 }
You can’t perform that action at this time.
0 commit comments