From 99f04ec639b2149be58eee4a0cfef607a68b7cc4 Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Thu, 12 Sep 2024 23:02:05 +0100 Subject: [PATCH] context_servers: fixup protocol --- crates/assistant/src/slash_command/context_server_command.rs | 4 ++-- crates/context_servers/src/types.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/assistant/src/slash_command/context_server_command.rs b/crates/assistant/src/slash_command/context_server_command.rs index f5fccae739c45..658aaf01342a8 100644 --- a/crates/assistant/src/slash_command/context_server_command.rs +++ b/crates/assistant/src/slash_command/context_server_command.rs @@ -230,7 +230,7 @@ fn format_messages(messages: &[SamplingMessage]) -> String { .iter() .map(|msg| { match &msg.content { - SamplingContent::Text(text) => text, + SamplingContent::Text { text } => text, SamplingContent::Image { .. } => "", // Ignore images for now } }) @@ -245,7 +245,7 @@ fn format_messages(messages: &[SamplingMessage]) -> String { SamplingRole::Assistant => "Assistant", }; let content = match &msg.content { - SamplingContent::Text(text) => text, + SamplingContent::Text { text } => text, SamplingContent::Image { .. } => "", }; format!("{}: {}", role, content) diff --git a/crates/context_servers/src/types.rs b/crates/context_servers/src/types.rs index de221631c53a9..84c425988c611 100644 --- a/crates/context_servers/src/types.rs +++ b/crates/context_servers/src/types.rs @@ -160,10 +160,11 @@ pub enum SamplingRole { } #[derive(Debug, Deserialize)] -#[serde(tag = "type", content = "content")] +#[serde(tag = "type")] pub enum SamplingContent { #[serde(rename = "text")] - Text(String), + Text { text: String }, + // Keep the Image variant if it's still needed #[serde(rename = "image")] Image { data: String, mime_type: String }, }