fix: handle MessageContent enum in responses API conversion

- Update request.rs to handle new MessageContent enum structure from main
- MessageContent can now be Text(String) or Items(Vec<InputContent>)
- Handle new InputItem variants (ItemReference, FunctionCallOutput)
- Fixes compilation error after merging latest main (#632)
This commit is contained in:
Adil Hafeez 2025-12-16 17:44:30 -08:00
parent 1fc39d5dcf
commit fc52274836
No known key found for this signature in database
GPG key ID: 9B18EF7691369645

View file

@ -220,16 +220,21 @@ impl ProviderRequestType {
}; };
// Extract text from message content // Extract text from message content
let content = msg.content.iter() let content = match &msg.content {
.filter_map(|c| { crate::apis::openai_responses::MessageContent::Text(text) => text.clone(),
if let crate::apis::openai_responses::InputContent::InputText { text } = c { crate::apis::openai_responses::MessageContent::Items(items) => {
Some(text.clone()) items.iter()
} else { .filter_map(|c| {
None if let crate::apis::openai_responses::InputContent::InputText { text } = c {
} Some(text.clone())
}) } else {
.collect::<Vec<_>>() None
.join("\n"); }
})
.collect::<Vec<_>>()
.join("\n")
}
};
openai_messages.push(Message { openai_messages.push(Message {
role, role,
@ -239,6 +244,10 @@ impl ProviderRequestType {
tool_call_id: None, tool_call_id: None,
}); });
} }
// Skip other input item types for now
InputItem::ItemReference { .. } | InputItem::FunctionCallOutput { .. } => {
// These are not yet supported in agent framework
}
} }
} }
} }