Add metadata to ModelSettings (#431)

This commit is contained in:
Drew Youngwerth 2025-04-03 14:50:24 -07:00 committed by GitHub
parent bef3394859
commit 0110f3ad96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 0 deletions

View file

@ -40,6 +40,9 @@ class ModelSettings:
max_tokens: int | None = None
"""The maximum number of output tokens to generate."""
metadata: dict[str, str] | None = None
"""Metadata to include with the model response call."""
store: bool | None = None
"""Whether to store the generated model response for later retrieval.
Defaults to True if not provided."""

View file

@ -537,6 +537,7 @@ class OpenAIChatCompletionsModel(Model):
stream_options={"include_usage": True} if stream else NOT_GIVEN,
store=store,
extra_headers=_HEADERS,
metadata=model_settings.metadata,
)
if isinstance(ret, ChatCompletion):

View file

@ -247,6 +247,7 @@ class OpenAIResponsesModel(Model):
extra_headers=_HEADERS,
text=response_format,
store=self._non_null_or_not_given(model_settings.store),
metadata=model_settings.metadata,
)
def _get_client(self) -> AsyncOpenAI: