Skip to content

Commit 317fb86

Browse files
authored
openai[patch]: fix int test (#29395)
1 parent 8d566a8 commit 317fb86

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

libs/partners/openai/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test tests:
2121
TIKTOKEN_CACHE_DIR=tiktoken_cache poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
2222

2323
integration_test integration_tests:
24-
poetry run pytest $(TEST_FILE)
24+
poetry run pytest -n auto $(TEST_FILE)
2525

2626
test_watch:
2727
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)

libs/partners/openai/poetry.lock

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/partners/openai/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pytest-watcher = "^0.3.4"
6767
pytest-asyncio = "^0.21.1"
6868
pytest-cov = "^4.1.0"
6969
pytest-socket = "^0.6.0"
70+
pytest-xdist = "^3.6.1"
7071
[[tool.poetry.group.test.dependencies.numpy]]
7172
version = "^1"
7273
python = "<3.12"

libs/partners/openai/tests/integration_tests/chat_models/test_base.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
magic_function as invalid_magic_function,
2828
)
2929
from pydantic import BaseModel, Field
30-
from typing_extensions import TypedDict
3130

3231
from langchain_openai import ChatOpenAI
3332
from tests.unit_tests.fake.callbacks import FakeCallbackHandler
@@ -643,7 +642,7 @@ def test_disable_parallel_tool_calling() -> None:
643642
assert len(result.tool_calls) == 1
644643

645644

646-
@pytest.mark.parametrize("model", ["gpt-4o-mini", "o1"])
645+
@pytest.mark.parametrize("model", ["gpt-4o-mini", "o1", "gpt-4"])
647646
def test_openai_structured_output(model: str) -> None:
648647
class MyModel(BaseModel):
649648
"""A Person"""
@@ -658,24 +657,6 @@ class MyModel(BaseModel):
658657
assert result.age == 27
659658

660659

661-
def test_structured_output_errors_with_legacy_models() -> None:
662-
class MyModel(BaseModel):
663-
"""A Person"""
664-
665-
name: str
666-
age: int
667-
668-
llm = ChatOpenAI(model="gpt-4").with_structured_output(MyModel)
669-
670-
with pytest.warns(UserWarning, match="with_structured_output"):
671-
with pytest.raises(openai.BadRequestError):
672-
_ = llm.invoke("I'm a 27 year old named Erick")
673-
674-
with pytest.warns(UserWarning, match="with_structured_output"):
675-
with pytest.raises(openai.BadRequestError):
676-
_ = list(llm.stream("I'm a 27 year old named Erick"))
677-
678-
679660
def test_openai_proxy() -> None:
680661
"""Test ChatOpenAI with proxy."""
681662
chat_openai = ChatOpenAI(openai_proxy="http://localhost:8080")
@@ -1221,14 +1202,3 @@ def test_o1_doesnt_stream() -> None:
12211202
def test_o1_stream_default_works() -> None:
12221203
result = list(ChatOpenAI(model="o1").stream("say 'hi'"))
12231204
assert len(result) > 0
1224-
1225-
1226-
def test_structured_output_old_model() -> None:
1227-
class Output(TypedDict):
1228-
"""output."""
1229-
1230-
foo: str
1231-
1232-
llm = ChatOpenAI(model="gpt-4").with_structured_output(Output)
1233-
output = llm.invoke("bar")
1234-
assert "foo" in output

0 commit comments

Comments
 (0)