Skip to content
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
2 changes: 1 addition & 1 deletion llm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def __init__(
self.schema = schema
self.tools = _wrap_tools(tools or [])
self.tool_results = tool_results or []
self.options = options or {}
self.options = options or model.Options()
self.hide_reasoning = hide_reasoning
# Explicit messages= list, if the caller supplied one. Copied so
# later mutation by the caller doesn't alter the Prompt.
Expand Down
23 changes: 23 additions & 0 deletions tests/test_options_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@

import pytest

import llm


@pytest.mark.parametrize("kwargs", ({}, {"options": None}, {"options": {}}))
def test_direct_prompt_default_options(mocked_openai_responses, kwargs):
model = llm.get_model("gpt-5.5")
prompt = llm.Prompt("hello", model, **kwargs)
response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key")

assert response.text() == "Bob, Alice, Eve"
assert isinstance(prompt.options, model.Options)
assert prompt.options == model.Options()


def test_direct_prompt_preserves_options(mocked_openai_responses):
model = llm.get_model("gpt-5.5")
options = model.Options(temperature=0.5)
prompt = llm.Prompt("hello", model, options=options)
response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key")

assert response.text() == "Bob, Alice, Eve"
assert prompt.options is options


def test_prompt_with_options_dict(mock_model):
mock_model.enqueue(["ok"])
Expand Down