From 467fa6519ef75043ffaec53b40e936602244de3e Mon Sep 17 00:00:00 2001 From: Searoc Date: Sat, 8 Feb 2025 16:29:24 +0800 Subject: [PATCH 1/4] fix(openai): wrong tag name for tool message --- rig-core/src/providers/openai.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rig-core/src/providers/openai.rs b/rig-core/src/providers/openai.rs index 01c9114c..9c5b0297 100644 --- a/rig-core/src/providers/openai.rs +++ b/rig-core/src/providers/openai.rs @@ -469,7 +469,7 @@ pub enum Message { #[serde(default, deserialize_with = "json_utils::null_or_vec")] tool_calls: Vec, }, - #[serde(rename = "Tool")] + #[serde(rename = "tool")] ToolResult { tool_call_id: String, content: OneOrMany, From 495bd69bc412db400ef0974594b8cecec78cb9ee Mon Sep 17 00:00:00 2001 From: Searoc Date: Sat, 8 Feb 2025 16:46:48 +0800 Subject: [PATCH 2/4] fix(openai): wrong id field in ToolCall conversion --- rig-core/src/providers/openai.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rig-core/src/providers/openai.rs b/rig-core/src/providers/openai.rs index 9c5b0297..2e82762f 100644 --- a/rig-core/src/providers/openai.rs +++ b/rig-core/src/providers/openai.rs @@ -407,7 +407,7 @@ impl TryFrom for completion::CompletionResponse Date: Sat, 8 Feb 2025 17:37:12 +0800 Subject: [PATCH 3/4] fix(openai): missing type field in ToolResultContent --- rig-core/src/providers/openai.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rig-core/src/providers/openai.rs b/rig-core/src/providers/openai.rs index 2e82762f..9dfc1377 100644 --- a/rig-core/src/providers/openai.rs +++ b/rig-core/src/providers/openai.rs @@ -534,9 +534,18 @@ pub struct InputAudio { #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] pub struct ToolResultContent { + #[serde(default)] + r#type: ToolResultContentType, text: String, } +#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)] +#[serde(rename_all = "lowercase")] +pub enum ToolResultContentType { + #[default] + Text, +} + impl FromStr for ToolResultContent { type Err = Infallible; @@ -547,7 +556,10 @@ impl FromStr for ToolResultContent { impl From for ToolResultContent { fn from(s: String) -> Self { - ToolResultContent { text: s } + ToolResultContent { + r#type: ToolResultContentType::default(), + text: s + } } } From 42ecc7f30d6af2e4db90fe4178cbf853513bf6e8 Mon Sep 17 00:00:00 2001 From: Searoc Date: Tue, 18 Feb 2025 01:18:01 +0800 Subject: [PATCH 4/4] style: cargo fmt --- rig-core/src/providers/openai.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rig-core/src/providers/openai.rs b/rig-core/src/providers/openai.rs index 9dfc1377..a9aa0736 100644 --- a/rig-core/src/providers/openai.rs +++ b/rig-core/src/providers/openai.rs @@ -558,7 +558,7 @@ impl From for ToolResultContent { fn from(s: String) -> Self { ToolResultContent { r#type: ToolResultContentType::default(), - text: s + text: s, } } }