Skip to content

The seed for the random number generator included #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/agents/model_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class ModelSettings:
max_tokens: int | None = None
"""The maximum number of output tokens to generate."""

seed: int | None = None
"""The random seed to use when calling the model."""

store: bool | None = None
"""Whether to store the generated model response for later retrieval.
Defaults to True if not provided."""
Expand Down
1 change: 1 addition & 0 deletions src/agents/models/openai_chatcompletions.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ async def _fetch_response(
stream=stream,
stream_options={"include_usage": True} if stream else NOT_GIVEN,
store=store,
seed=self._non_null_or_not_given(model_settings.seed),
extra_headers=_HEADERS,
)

Expand Down
3 changes: 1 addition & 2 deletions src/agents/models/openai_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ async def _fetch_response(
stream=stream,
extra_headers=_HEADERS,
text=response_format,
store=self._non_null_or_not_given(model_settings.store),
)
store=self._non_null_or_not_given(model_settings.store))

def _get_client(self) -> AsyncOpenAI:
if self._client is None:
Expand Down