test_json_schema_openai_format() — langchain Function Reference
Architecture documentation for the test_json_schema_openai_format() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 0b431c17_d0a4_be5f_6a75_9f5a753ac3e3["test_json_schema_openai_format()"] bd382a4e_442c_13ae_530c_6e34bc43623d["test_base.py"] 0b431c17_d0a4_be5f_6a75_9f5a753ac3e3 -->|defined in| bd382a4e_442c_13ae_530c_6e34bc43623d style 0b431c17_d0a4_be5f_6a75_9f5a753ac3e3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 860–888
def test_json_schema_openai_format(
strict: bool, method: Literal["json_schema", "function_calling"]
) -> None:
"""Test we can pass in OpenAI schema format specifying strict."""
llm = ChatOpenAI(model="gpt-5-nano")
schema = {
"name": "get_weather",
"description": "Fetches the weather in the given location",
"strict": strict,
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The location to get the weather for",
},
"unit": {
"type": "string",
"description": "The unit to return the temperature in",
"enum": ["F", "C"],
},
},
"additionalProperties": False,
"required": ["location", "unit"],
},
}
chat = llm.with_structured_output(schema, method=method)
result = chat.invoke("What is the weather in New York?")
assert isinstance(result, dict)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_json_schema_openai_format() do?
test_json_schema_openai_format() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py.
Where is test_json_schema_openai_format() defined?
test_json_schema_openai_format() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py at line 860.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free