File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
examples/chat/create_chat_completion/src Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1818 . messages ( vec ! [
1919 ChatMessage :: User {
2020 content: ChatMessageContent :: Text ( "Hello!" . to_string( ) ) ,
21- name: None ,
21+ name: Some ( "Judy" . to_string ( ) ) ,
2222 } ,
2323 ChatMessage :: User {
24- content: ChatMessageContent :: Text ( "What is the capital of Vietnam ?" . to_string( ) ) ,
25- name: None ,
24+ content: ChatMessageContent :: Text ( "What is the capital of Singapore ?" . to_string( ) ) ,
25+ name: Some ( "Judy" . to_string ( ) ) ,
2626 } ,
2727 ] )
2828 . response_format ( ChatCompletionResponseFormat :: Text )
@@ -32,5 +32,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3232
3333 println ! ( "{:#?}" , result) ;
3434
35+ for choice in & result. choices {
36+ if let Some ( text) = choice. message . text ( ) {
37+ println ! ( "{}" , text) ;
38+ }
39+ }
40+
3541 Ok ( ( ) )
3642}
Original file line number Diff line number Diff line change 11[package ]
22name = " openai_dive"
3- version = " 1.2.1 "
3+ version = " 1.2.2 "
44edition = " 2021"
55license = " MIT"
66description = " OpenAI Dive is an unofficial async Rust library that allows you to interact with the OpenAI API."
You can’t perform that action at this time.
0 commit comments