From 03b573e1bed168c4dac02e36b3507f6ffa42e396 Mon Sep 17 00:00:00 2001 From: Searoc Date: Sat, 8 Feb 2025 17:37:12 +0800 Subject: [PATCH] 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 a6a31eaf..1bd0fcdf 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 + } } }