From 7e10e3a293218210db6513c96399e74c0ebe3df3 Mon Sep 17 00:00:00 2001 From: hansel Date: Wed, 17 Jul 2024 09:45:50 +0800 Subject: [PATCH] add tool_calls to ChatCompletionMessage --- README.md | 1 + examples/chat_completion.rs | 1 + examples/function_call.rs | 1 + examples/function_call_role.rs | 1 + examples/vision.rs | 1 + src/v1/chat_completion.rs | 2 ++ 6 files changed, 7 insertions(+) diff --git a/README.md b/README.md index c0e6809..cf440d4 100644 --- a/README.md +++ b/README.md @@ -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, }], ); ``` diff --git a/examples/chat_completion.rs b/examples/chat_completion.rs index d53134f..6ef5035 100644 --- a/examples/chat_completion.rs +++ b/examples/chat_completion.rs @@ -13,6 +13,7 @@ async fn main() -> Result<(), Box> { role: chat_completion::MessageRole::user, content: chat_completion::Content::Text(String::from("What is bitcoin?")), name: None, + tool_calls: None, }], ); diff --git a/examples/function_call.rs b/examples/function_call.rs index 27c6375..d2ce8cb 100644 --- a/examples/function_call.rs +++ b/examples/function_call.rs @@ -34,6 +34,7 @@ async fn main() -> Result<(), Box> { 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 { diff --git a/examples/function_call_role.rs b/examples/function_call_role.rs index dcdf7ad..a6bf064 100644 --- a/examples/function_call_role.rs +++ b/examples/function_call_role.rs @@ -34,6 +34,7 @@ async fn main() -> Result<(), Box> { 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 { diff --git a/examples/vision.rs b/examples/vision.rs index b62a653..056feef 100644 --- a/examples/vision.rs +++ b/examples/vision.rs @@ -28,6 +28,7 @@ async fn main() -> Result<(), Box> { }, ]), name: None, + tool_calls: None, }], ); diff --git a/src/v1/chat_completion.rs b/src/v1/chat_completion.rs index b9353b6..1536f9d 100644 --- a/src/v1/chat_completion.rs +++ b/src/v1/chat_completion.rs @@ -156,6 +156,8 @@ pub struct ChatCompletionMessage { pub content: Content, #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tool_calls: Option>, } #[derive(Debug, Deserialize, Serialize)]