base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 11 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6a343e52_a687_7d99_5617_2a13923de0ef["base.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 6a343e52_a687_7d99_5617_2a13923de0ef --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 6a343e52_a687_7d99_5617_2a13923de0ef --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"] 6a343e52_a687_7d99_5617_2a13923de0ef --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7 ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] 6a343e52_a687_7d99_5617_2a13923de0ef --> ba43b74d_3099_7e1c_aac3_cf594720469e 83d7c7fd_1989_762c_9cf3_cecb50ada22b["langchain_core.output_parsers"] 6a343e52_a687_7d99_5617_2a13923de0ef --> 83d7c7fd_1989_762c_9cf3_cecb50ada22b 89a4ade4_215f_cae5_8190_9505303396df["langchain_core.output_parsers.openai_functions"] 6a343e52_a687_7d99_5617_2a13923de0ef --> 89a4ade4_215f_cae5_8190_9505303396df e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] 6a343e52_a687_7d99_5617_2a13923de0ef --> e6b4f61e_7b98_6666_3641_26b069517d4a a6f93333_6d02_5473_677b_843422594588["langchain_core.utils.function_calling"] 6a343e52_a687_7d99_5617_2a13923de0ef --> a6f93333_6d02_5473_677b_843422594588 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 6a343e52_a687_7d99_5617_2a13923de0ef --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 9b4ec80f_d8de_a6e0_4f16_67ba56685088["langchain_classic.chains"] 6a343e52_a687_7d99_5617_2a13923de0ef --> 9b4ec80f_d8de_a6e0_4f16_67ba56685088 6c654bba_4af4_d7a5_446e_b6a3353cd969["langchain_classic.chains.structured_output.base"] 6a343e52_a687_7d99_5617_2a13923de0ef --> 6c654bba_4af4_d7a5_446e_b6a3353cd969 style 6a343e52_a687_7d99_5617_2a13923de0ef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Methods for creating chains that use OpenAI function-calling APIs."""
from collections.abc import Callable, Sequence
from typing import (
Any,
)
from langchain_core._api import deprecated
from langchain_core.language_models import BaseLanguageModel
from langchain_core.output_parsers import (
BaseLLMOutputParser,
)
from langchain_core.output_parsers.openai_functions import (
PydanticAttrOutputFunctionsParser,
)
from langchain_core.prompts import BasePromptTemplate
from langchain_core.utils.function_calling import (
PYTHON_TO_JSON_TYPES,
convert_to_openai_function,
)
from pydantic import BaseModel
from langchain_classic.chains import LLMChain
from langchain_classic.chains.structured_output.base import (
create_openai_fn_runnable,
create_structured_output_runnable,
get_openai_output_parser,
)
__all__ = [
"PYTHON_TO_JSON_TYPES", # backwards compatibility
"convert_to_openai_function", # backwards compatibility
"create_openai_fn_chain", # deprecated
"create_openai_fn_runnable",
"create_structured_output_chain", # deprecated
"create_structured_output_runnable", # deprecated
"get_openai_output_parser",
]
@deprecated(since="0.1.1", removal="1.0", alternative="create_openai_fn_runnable")
def create_openai_fn_chain(
functions: Sequence[dict[str, Any] | type[BaseModel] | Callable],
llm: BaseLanguageModel,
prompt: BasePromptTemplate,
*,
enforce_single_function_usage: bool = True,
output_key: str = "function",
output_parser: BaseLLMOutputParser | None = None,
**kwargs: Any,
) -> LLMChain:
"""[Legacy] Create an LLM chain that uses OpenAI functions.
Args:
functions: A sequence of either dictionaries, pydantic.BaseModels classes, or
Python functions. If dictionaries are passed in, they are assumed to
already be a valid OpenAI functions. If only a single
function is passed in, then it will be enforced that the model use that
function. pydantic.BaseModels and Python functions should have docstrings
describing what the function does. For best results, pydantic.BaseModels
// ... (180 more lines)
Domain
Subdomains
Classes
Dependencies
- collections.abc
- langchain_classic.chains
- langchain_classic.chains.structured_output.base
- langchain_core._api
- langchain_core.language_models
- langchain_core.output_parsers
- langchain_core.output_parsers.openai_functions
- langchain_core.prompts
- langchain_core.utils.function_calling
- pydantic
- typing
Source
Frequently Asked Questions
What does base.py do?
base.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in base.py?
base.py defines 2 function(s): create_openai_fn_chain, create_structured_output_chain.
What does base.py depend on?
base.py imports 11 module(s): collections.abc, langchain_classic.chains, langchain_classic.chains.structured_output.base, langchain_core._api, langchain_core.language_models, langchain_core.output_parsers, langchain_core.output_parsers.openai_functions, langchain_core.prompts, and 3 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/chains/openai_functions/base.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/langchain_classic/chains/openai_functions).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free