mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 18:50:33 +00:00
openai[patch]: type reasoning_effort (#28825)
This commit is contained in:
@@ -1089,19 +1089,13 @@ async def test_astream_response_format() -> None:
|
||||
pass
|
||||
|
||||
|
||||
def test_o1_max_tokens() -> None:
|
||||
response = ChatOpenAI(model="o1-mini", max_tokens=10).invoke("how are you") # type: ignore[call-arg]
|
||||
assert isinstance(response, AIMessage)
|
||||
|
||||
response = ChatOpenAI(model="gpt-4o", max_completion_tokens=10).invoke(
|
||||
"how are you"
|
||||
)
|
||||
assert isinstance(response, AIMessage)
|
||||
|
||||
|
||||
def test_developer_message() -> None:
|
||||
llm = ChatOpenAI(model="o1", max_tokens=10) # type: ignore[call-arg]
|
||||
response = llm.invoke(
|
||||
@pytest.mark.parametrize("use_max_completion_tokens", [True, False])
|
||||
def test_o1(use_max_completion_tokens: bool) -> None:
|
||||
if use_max_completion_tokens:
|
||||
kwargs: dict = {"max_completion_tokens": 10}
|
||||
else:
|
||||
kwargs = {"max_tokens": 10}
|
||||
response = ChatOpenAI(model="o1", reasoning_effort="low", **kwargs).invoke(
|
||||
[
|
||||
{"role": "developer", "content": "respond in all caps"},
|
||||
{"role": "user", "content": "HOW ARE YOU"},
|
||||
|
||||
@@ -882,3 +882,9 @@ def test__get_request_payload() -> None:
|
||||
}
|
||||
payload = llm._get_request_payload(messages)
|
||||
assert payload == expected
|
||||
|
||||
|
||||
def test_init_o1() -> None:
|
||||
with pytest.warns(None) as record: # type: ignore[call-overload]
|
||||
ChatOpenAI(model="o1", reasoning_effort="medium")
|
||||
assert len(record) == 0
|
||||
|
||||
Reference in New Issue
Block a user