open_ai: Fix issues with OpenAI compatible APIs (#32982)

Ran into this while adding support for Vercel v0s models:
- The timestamp seems to be returned in Milliseconds instead of seconds
so it breaks the bounds of `created: u32`. We did not use this field
anywhere so just decided to remove it
- Sometimes the `choices` field can be empty when the last chunk comes
in because it only contains `usage`

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-06-18 23:51:51 +02:00 committed by GitHub
parent 05f944b83a
commit c34b24b5fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 4 deletions

View file

@ -529,9 +529,7 @@ impl OpenAiEventMapper {
event: ResponseStreamEvent,
) -> Vec<Result<LanguageModelCompletionEvent, LanguageModelCompletionError>> {
let Some(choice) = event.choices.first() else {
return vec![Err(LanguageModelCompletionError::Other(anyhow!(
"Response contained no choices"
)))];
return Vec::new();
};
let mut events = Vec::new();

View file

@ -385,7 +385,6 @@ pub enum ResponseStreamResult {
#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseStreamEvent {
pub created: u32,
pub model: String,
pub choices: Vec<ChoiceDelta>,
pub usage: Option<Usage>,