Skip to content

Commit

Permalink
add tool calls to messages
Browse files Browse the repository at this point in the history
  • Loading branch information
magdyksaleh committed Jan 23, 2025
1 parent dd4452b commit 4ac3014
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ pub struct Url {
}

#[derive(Clone, Deserialize, Serialize, ToSchema, Default, Debug, PartialEq)]
pub(crate) struct ToolCall {
pub struct ToolCall {
pub id: String,
pub r#type: String,
pub function: ReturnFunctionDefinition,
Expand All @@ -603,6 +603,8 @@ pub struct Message {
#[schema(example = "My name is David and I")]
pub content: Option<MessageContent>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool_calls: Option<Vec<ToolCall>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schema(example = "\"David\"")]
name: Option<String>,
}
Expand Down Expand Up @@ -642,6 +644,8 @@ pub struct TextMessage {
pub role: String,
#[schema(example = "My name is David and I")]
pub content: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool_calls: Option<Vec<ToolCall>>,
}

impl From<Message> for TextMessage {
Expand All @@ -660,6 +664,7 @@ impl From<Message> for TextMessage {
.join(""),
None => String::new(),
},
tool_calls: value.tool_calls,
}
}
}
Expand Down

0 comments on commit 4ac3014

Please sign in to comment.