mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-22 15:38:06 +00:00
patch openai json mode test (#28831)
This commit is contained in:
parent
ce6748dbfe
commit
c3ccd93c12
@ -930,7 +930,8 @@ def test_nested_structured_output_strict(
|
|||||||
def test_json_mode() -> None:
|
def test_json_mode() -> None:
|
||||||
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
||||||
response = llm.invoke(
|
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 isinstance(response.content, str)
|
||||||
assert json.loads(response.content) == {"a": 1}
|
assert json.loads(response.content) == {"a": 1}
|
||||||
@ -949,7 +950,7 @@ def test_json_mode() -> None:
|
|||||||
async def test_json_mode_async() -> None:
|
async def test_json_mode_async() -> None:
|
||||||
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
|
||||||
response = await llm.ainvoke(
|
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 isinstance(response.content, str)
|
||||||
assert json.loads(response.content) == {"a": 1}
|
assert json.loads(response.content) == {"a": 1}
|
||||||
|
Loading…
Reference in New Issue
Block a user