File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " openai_api_rust"
3- version = " 0.1.3 "
3+ version = " 0.1.4 "
44authors = [" i@guantong.dev" ]
55edition = " 2021"
66license = " MIT"
Original file line number Diff line number Diff line change @@ -64,15 +64,14 @@ fn main() {
6464 logit_bias : None ,
6565 user : None ,
6666 messages : vec! [Message {
67- role : Some ( " user" . to_string () ),
68- content : Some ( " Hello!" . to_string () ),
67+ role : " user" . to_string (),
68+ content : " Hello!" . to_string (),
6969 }],
7070 };
7171 let rs = openai . chat_completion_create (& body );
7272 let choice = rs . unwrap (). choices;
7373 let message = & choice [0 ]. message. as_ref (). unwrap ();
74- let content = message . content. as_ref (). unwrap ();
75- assert! (content . contains (" Hello" ));
74+ assert! (message . content. contains (" Hello" ));
7675}
7776```
7877
Original file line number Diff line number Diff line change @@ -121,14 +121,13 @@ mod tests {
121121 logit_bias : None ,
122122 user : None ,
123123 messages : vec ! [ Message {
124- role: Some ( "user" . to_string( ) ) ,
125- content: Some ( "Hello!" . to_string( ) ) ,
124+ role: "user" . to_string( ) ,
125+ content: "Hello!" . to_string( ) ,
126126 } ] ,
127127 } ;
128128 let rs = openai. chat_completion_create ( & body) ;
129129 let choice = rs. unwrap ( ) . choices ;
130130 let message = & choice[ 0 ] . message . as_ref ( ) . unwrap ( ) ;
131- let content = message. content . as_ref ( ) . unwrap ( ) ;
132- assert ! ( content. contains( "Hello" ) ) ;
131+ assert ! ( message. content. contains( "Hello" ) ) ;
133132 }
134133}
Original file line number Diff line number Diff line change @@ -137,8 +137,8 @@ pub struct Choice {
137137
138138#[ derive( Debug , Serialize , Deserialize ) ]
139139pub struct Message {
140- pub role : Option < String > ,
141- pub content : Option < String > ,
140+ pub role : String ,
141+ pub content : String ,
142142}
143143
144144pub trait CompletionsApi {
You can’t perform that action at this time.
0 commit comments