Skip to content

Commit 6f93345

Browse files
author
Guantong
committed
User & Content should not be Option
1 parent d3fa489 commit 6f93345

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "openai_api_rust"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
authors = ["i@guantong.dev"]
55
edition = "2021"
66
license = "MIT"

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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

src/apis/chat.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

src/apis/completions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ pub struct Choice {
137137

138138
#[derive(Debug, Serialize, Deserialize)]
139139
pub struct Message {
140-
pub role: Option<String>,
141-
pub content: Option<String>,
140+
pub role: String,
141+
pub content: String,
142142
}
143143

144144
pub trait CompletionsApi {

0 commit comments

Comments
 (0)