Skip to content

Commit

Permalink
patch openai json mode test (#28831)
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan authored Dec 19, 2024
1 parent ce6748d commit c3ccd93
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit c3ccd93

Please sign in to comment.