test_openai_functions.py — langchain Source File
Architecture documentation for test_openai_functions.py, a python file in the langchain codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f074218e_93c8_6d4c_b53c_2850f3240e27["test_openai_functions.py"] 5c738c12_cc4f_cee1_0e1d_562012a5f844["langchain_core.utils.function_calling"] f074218e_93c8_6d4c_b53c_2850f3240e27 --> 5c738c12_cc4f_cee1_0e1d_562012a5f844 dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] f074218e_93c8_6d4c_b53c_2850f3240e27 --> dd5e7909_a646_84f1_497b_cae69735550e style f074218e_93c8_6d4c_b53c_2850f3240e27 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.utils.function_calling import convert_to_openai_function
from pydantic import BaseModel, Field
def test_convert_pydantic_to_openai_function() -> None:
class Data(BaseModel):
"""The data to return."""
key: str = Field(..., description="API key")
days: int = Field(default=0, description="Number of days to forecast")
actual = convert_to_openai_function(Data)
expected = {
"name": "Data",
"description": "The data to return.",
"parameters": {
"type": "object",
"properties": {
"key": {"description": "API key", "type": "string"},
"days": {
"description": "Number of days to forecast",
"default": 0,
"type": "integer",
},
},
"required": ["key"],
},
}
assert actual == expected
def test_convert_pydantic_to_openai_function_nested() -> None:
class Data(BaseModel):
"""The data to return."""
key: str = Field(..., description="API key")
days: int = Field(default=0, description="Number of days to forecast")
class Model(BaseModel):
"""The model to return."""
data: Data
actual = convert_to_openai_function(Model)
expected = {
"name": "Model",
"description": "The model to return.",
"parameters": {
"type": "object",
"properties": {
"data": {
"description": "The data to return.",
"type": "object",
"properties": {
"key": {
"description": "API key",
"type": "string",
},
"days": {
"description": "Number of days to forecast",
"default": 0,
"type": "integer",
},
},
"required": ["key"],
},
},
"required": ["data"],
},
}
assert actual == expected
Domain
Subdomains
Functions
Dependencies
- langchain_core.utils.function_calling
- pydantic
Source
Frequently Asked Questions
What does test_openai_functions.py do?
test_openai_functions.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What functions are defined in test_openai_functions.py?
test_openai_functions.py defines 2 function(s): test_convert_pydantic_to_openai_function, test_convert_pydantic_to_openai_function_nested.
What does test_openai_functions.py depend on?
test_openai_functions.py imports 2 module(s): langchain_core.utils.function_calling, pydantic.
Where is test_openai_functions.py in the architecture?
test_openai_functions.py is located at libs/langchain/tests/unit_tests/utils/test_openai_functions.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/langchain/tests/unit_tests/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free