update code to use new json based system prompt for routing (#493)

This commit is contained in:
Adil Hafeez 2025-05-30 17:40:46 -07:00 committed by GitHub
parent 8d12a9a6e0
commit 0d190a6e5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 433 additions and 283 deletions

View file

@ -162,6 +162,8 @@ pub struct StreamOptions {
pub enum MultiPartContentType {
#[serde(rename = "text")]
Text,
#[serde(rename = "image_url")]
ImageUrl,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@ -188,6 +190,9 @@ impl Display for ContentType {
.filter_map(|part| {
if part.content_type == MultiPartContentType::Text {
part.text.clone()
} else if part.content_type == MultiPartContentType::ImageUrl {
// skip image URLs or their data in text representation
None
} else {
panic!("Unsupported content type: {:?}", part.content_type);
}
@ -217,6 +222,19 @@ pub struct Message {
pub tool_call_id: Option<String>,
}
impl Message {
pub fn new(role: String, content: String) -> Self {
let content = Some(ContentType::Text(content));
Message {
role,
content,
model: None,
tool_calls: None,
tool_call_id: None,
}
}
}
impl Default for Message {
fn default() -> Self {
Message {