Skip to content

Commit db2a0dc

Browse files
authored
Parser for openai must have created as an optional field (#1778)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Makes `created` field in `ChatCompletionGeneric` optional during deserialization to handle missing values in OpenAI responses. > > - **Deserialization**: > - Makes `created` field in `ChatCompletionGeneric` optional by adding `#[serde(default, ...)]`, allowing missing `created` in OpenAI responses to deserialize as `None`. > - **Scope**: > - Change is limited to `types.rs`, only affects `ChatCompletionGeneric` struct. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 81ef224. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent b2dc8d0 commit db2a0dc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • engine/baml-runtime/src/internal/llm_client/primitive/openai

engine/baml-runtime/src/internal/llm_client/primitive/openai/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct ChatCompletionGeneric<C> {
1414
/// A list of chat completion choices. Can be more than one if `n` is greater than 1.s
1515
pub choices: Vec<C>,
1616
/// The Unix timestamp (in seconds) of when the chat completion was created.
17-
#[serde(deserialize_with = "deserialize_float_to_u32")]
17+
#[serde(default, deserialize_with = "deserialize_float_to_u32")]
1818
pub created: Option<u32>,
1919
/// The model used for the chat completion.
2020
pub model: String,

0 commit comments

Comments
 (0)