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>> {
18
18
. messages ( vec ! [
19
19
ChatMessage :: User {
20
20
content: ChatMessageContent :: Text ( "Hello!" . to_string( ) ) ,
21
- name: None ,
21
+ name: Some ( "Judy" . to_string ( ) ) ,
22
22
} ,
23
23
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 ( ) ) ,
26
26
} ,
27
27
] )
28
28
. response_format ( ChatCompletionResponseFormat :: Text )
@@ -32,5 +32,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
32
32
33
33
println ! ( "{:#?}" , result) ;
34
34
35
+ for choice in & result. choices {
36
+ if let Some ( text) = choice. message . text ( ) {
37
+ println ! ( "{}" , text) ;
38
+ }
39
+ }
40
+
35
41
Ok ( ( ) )
36
42
}
Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " openai_dive"
3
- version = " 1.2.1 "
3
+ version = " 1.2.2 "
4
4
edition = " 2021"
5
5
license = " MIT"
6
6
description = " 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