mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
openai[patch]: fix int test (#29395)
This commit is contained in:
@@ -27,7 +27,6 @@ from langchain_tests.integration_tests.chat_models import (
|
||||
magic_function as invalid_magic_function,
|
||||
)
|
||||
from pydantic import BaseModel, Field
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from langchain_openai import ChatOpenAI
|
||||
from tests.unit_tests.fake.callbacks import FakeCallbackHandler
|
||||
@@ -643,7 +642,7 @@ def test_disable_parallel_tool_calling() -> None:
|
||||
assert len(result.tool_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["gpt-4o-mini", "o1"])
|
||||
@pytest.mark.parametrize("model", ["gpt-4o-mini", "o1", "gpt-4"])
|
||||
def test_openai_structured_output(model: str) -> None:
|
||||
class MyModel(BaseModel):
|
||||
"""A Person"""
|
||||
@@ -658,24 +657,6 @@ def test_openai_structured_output(model: str) -> None:
|
||||
assert result.age == 27
|
||||
|
||||
|
||||
def test_structured_output_errors_with_legacy_models() -> None:
|
||||
class MyModel(BaseModel):
|
||||
"""A Person"""
|
||||
|
||||
name: str
|
||||
age: int
|
||||
|
||||
llm = ChatOpenAI(model="gpt-4").with_structured_output(MyModel)
|
||||
|
||||
with pytest.warns(UserWarning, match="with_structured_output"):
|
||||
with pytest.raises(openai.BadRequestError):
|
||||
_ = llm.invoke("I'm a 27 year old named Erick")
|
||||
|
||||
with pytest.warns(UserWarning, match="with_structured_output"):
|
||||
with pytest.raises(openai.BadRequestError):
|
||||
_ = list(llm.stream("I'm a 27 year old named Erick"))
|
||||
|
||||
|
||||
def test_openai_proxy() -> None:
|
||||
"""Test ChatOpenAI with proxy."""
|
||||
chat_openai = ChatOpenAI(openai_proxy="http://localhost:8080")
|
||||
@@ -1221,14 +1202,3 @@ def test_o1_doesnt_stream() -> None:
|
||||
def test_o1_stream_default_works() -> None:
|
||||
result = list(ChatOpenAI(model="o1").stream("say 'hi'"))
|
||||
assert len(result) > 0
|
||||
|
||||
|
||||
def test_structured_output_old_model() -> None:
|
||||
class Output(TypedDict):
|
||||
"""output."""
|
||||
|
||||
foo: str
|
||||
|
||||
llm = ChatOpenAI(model="gpt-4").with_structured_output(Output)
|
||||
output = llm.invoke("bar")
|
||||
assert "foo" in output
|
||||
|
||||
Reference in New Issue
Block a user