mirror of
https://github.com/hwchase17/langchain.git
synced 2025-04-27 19:46:55 +00:00
openai[patch]: add unit test (#30022)
Test `max_completion_tokens` is propagated to payload for AzureChatOpenAI.
This commit is contained in:
parent
156a60013a
commit
6c7c8a164f
@ -4,6 +4,7 @@ import os
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from langchain_core.messages import HumanMessage
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from langchain_openai import AzureChatOpenAI
|
||||
@ -81,3 +82,20 @@ def test_structured_output_old_model() -> None:
|
||||
# assert tool calling was used instead of json_schema
|
||||
assert "tools" in llm.steps[0].kwargs # type: ignore
|
||||
assert "response_format" not in llm.steps[0].kwargs # type: ignore
|
||||
|
||||
|
||||
def test_max_completion_tokens_in_payload() -> None:
|
||||
llm = AzureChatOpenAI(
|
||||
azure_deployment="o1-mini",
|
||||
api_version="2024-12-01-preview",
|
||||
azure_endpoint="my-base-url",
|
||||
model_kwargs={"max_completion_tokens": 300},
|
||||
)
|
||||
messages = [HumanMessage("Hello")]
|
||||
payload = llm._get_request_payload(messages)
|
||||
assert payload == {
|
||||
"messages": [{"content": "Hello", "role": "user"}],
|
||||
"model": None,
|
||||
"stream": False,
|
||||
"max_completion_tokens": 300,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user