Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch openai json mode test #28831

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ class JokeWithEvaluation(TypedDict):
def test_json_mode() -> None:
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
response = llm.invoke(
"Return this as json: {'a': 1}", response_format={"type": "json_object"}
"Return this as json: {'a': 1}. Do not return anything other than json. Do not include markdown codeblocks.", # noqa: E501
response_format={"type": "json_object"},
)
assert isinstance(response.content, str)
assert json.loads(response.content) == {"a": 1}
Expand All @@ -949,7 +950,7 @@ def test_json_mode() -> None:
async def test_json_mode_async() -> None:
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
response = await llm.ainvoke(
"Return this as json: {'a': 1}", response_format={"type": "json_object"}
"Return this as json: {'a': 1}. Do not return anything other than json. Do not include markdown codeblocks." # noqa: E501
)
assert isinstance(response.content, str)
assert json.loads(response.content) == {"a": 1}
Expand Down
Loading