From 6436f83a958f1c2ee274063a643b2411cc38baf2 Mon Sep 17 00:00:00 2001 From: Bao Phan Date: Tue, 14 May 2024 13:18:28 +0700 Subject: [PATCH] change ToolCall id to string --- router/src/lib.rs | 6 ++++-- router/src/server.rs | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/router/src/lib.rs b/router/src/lib.rs index 82199946..57bc84bf 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -882,7 +882,7 @@ pub(crate) struct ChatTemplateInputs<'a> { #[derive(Clone, Deserialize, Serialize, ToSchema, Default, Debug)] pub(crate) struct ToolCall { - pub id: u32, + pub id: String, pub r#type: String, pub function: FunctionDefinition, } @@ -955,13 +955,15 @@ pub(crate) struct Message { pub role: String, #[serde(skip_serializing_if = "Option::is_none")] #[schema(example = "My name is David and I")] - #[serde(deserialize_with = "message_content_serde::deserialize")] + #[serde(default, deserialize_with = "message_content_serde::deserialize")] pub content: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[schema(example = "\"David\"")] pub name: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub tool_calls: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[schema(example = "\"get_weather\"")] pub tool_call_id: Option, } diff --git a/router/src/server.rs b/router/src/server.rs index cb55d897..f51bbbef 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -988,7 +988,6 @@ async fn chat_completions( ) -> Result)> { let span = tracing::Span::current(); metrics::increment_counter!("tgi_request_count"); - let ChatRequest { logprobs, max_tokens, @@ -1160,7 +1159,7 @@ async fn chat_completions( ) })?; let tool_calls = vec![ToolCall { - id: 0, + id: "0".to_string(), r#type: "function".to_string(), function: FunctionDefinition { description: None,