Skip to content

Commit

Permalink
add tool_calls to ChatCompletionMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
hanselke committed Jul 17, 2024
1 parent 55b4b78 commit 7e10e3a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let req = ChatCompletionRequest::new(
role: chat_completion::MessageRole::user,
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
name: None,
tool_calls: None,
}],
);
```
Expand Down
1 change: 1 addition & 0 deletions examples/chat_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
role: chat_completion::MessageRole::user,
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
name: None,
tool_calls: None,
}],
);

Expand Down
1 change: 1 addition & 0 deletions examples/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
role: chat_completion::MessageRole::user,
content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
name: None,
tool_calls: None,
}],
)
.tools(vec![chat_completion::Tool {
Expand Down
1 change: 1 addition & 0 deletions examples/function_call_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
role: chat_completion::MessageRole::user,
content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
name: None,
tool_calls: None,
}],
)
.tools(vec![chat_completion::Tool {
Expand Down
1 change: 1 addition & 0 deletions examples/vision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
},
]),
name: None,
tool_calls: None,
}],
);

Expand Down
2 changes: 2 additions & 0 deletions src/v1/chat_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ pub struct ChatCompletionMessage {
pub content: Content,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_calls: Option<Vec<ToolCall>>,
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down

0 comments on commit 7e10e3a

Please sign in to comment.