__init__.py — langchain Source File
Architecture documentation for __init__.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c4a4ff34_6633_17cd_328d_9ed7360567d8["__init__.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 923d222e_e249_1c30_4cfe_3c907f050b78["langchain_core._import_utils"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 923d222e_e249_1c30_4cfe_3c907f050b78 3bd68d31_2a9b_9448_d8ba_c386f0e45f29["langchain_core.outputs.chat_generation"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 3bd68d31_2a9b_9448_d8ba_c386f0e45f29 10de79d5_a0f1_d6a2_4c20_abd3ee601196["langchain_core.outputs.chat_result"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 10de79d5_a0f1_d6a2_4c20_abd3ee601196 7f324a3e_1ccd_321c_fef1_09174d50081d["langchain_core.outputs.generation"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 7f324a3e_1ccd_321c_fef1_09174d50081d 884fdf32_1e49_8c1f_c69e_7f622e672b39["langchain_core.outputs.llm_result"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 884fdf32_1e49_8c1f_c69e_7f622e672b39 51a3ca9a_d40e_993f_6547_51772aeeda98["langchain_core.outputs.run_info"] c4a4ff34_6633_17cd_328d_9ed7360567d8 --> 51a3ca9a_d40e_993f_6547_51772aeeda98 style c4a4ff34_6633_17cd_328d_9ed7360567d8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Output classes.
Used to represent the output of a language model call and the output of a chat.
The top container for information is the `LLMResult` object. `LLMResult` is used by both
chat models and LLMs. This object contains the output of the language model and any
additional information that the model provider wants to return.
When invoking models via the standard runnable methods (e.g. invoke, batch, etc.):
- Chat models will return `AIMessage` objects.
- LLMs will return regular text strings.
In addition, users can access the raw output of either LLMs or chat models via
callbacks. The `on_chat_model_end` and `on_llm_end` callbacks will return an `LLMResult`
object containing the generated outputs and any additional information returned by the
model provider.
In general, if information is already available in the AIMessage object, it is
recommended to access it from there rather than from the `LLMResult` object.
"""
from typing import TYPE_CHECKING
from langchain_core._import_utils import import_attr
if TYPE_CHECKING:
from langchain_core.outputs.chat_generation import (
ChatGeneration,
ChatGenerationChunk,
)
from langchain_core.outputs.chat_result import ChatResult
from langchain_core.outputs.generation import Generation, GenerationChunk
from langchain_core.outputs.llm_result import LLMResult
from langchain_core.outputs.run_info import RunInfo
__all__ = (
"ChatGeneration",
"ChatGenerationChunk",
"ChatResult",
"Generation",
"GenerationChunk",
"LLMResult",
"RunInfo",
)
_dynamic_imports = {
"ChatGeneration": "chat_generation",
"ChatGenerationChunk": "chat_generation",
"ChatResult": "chat_result",
"Generation": "generation",
"GenerationChunk": "generation",
"LLMResult": "llm_result",
"RunInfo": "run_info",
}
def __getattr__(attr_name: str) -> object:
module_name = _dynamic_imports.get(attr_name)
result = import_attr(attr_name, module_name, __spec__.parent)
globals()[attr_name] = result
return result
def __dir__() -> list[str]:
return list(__all__)
Domain
Subdomains
Functions
Dependencies
- langchain_core._import_utils
- langchain_core.outputs.chat_generation
- langchain_core.outputs.chat_result
- langchain_core.outputs.generation
- langchain_core.outputs.llm_result
- langchain_core.outputs.run_info
- typing
Source
Frequently Asked Questions
What does __init__.py do?
__init__.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in __init__.py?
__init__.py defines 3 function(s): __dir__, __getattr__, langchain_core.
What does __init__.py depend on?
__init__.py imports 7 module(s): langchain_core._import_utils, langchain_core.outputs.chat_generation, langchain_core.outputs.chat_result, langchain_core.outputs.generation, langchain_core.outputs.llm_result, langchain_core.outputs.run_info, typing.
Where is __init__.py in the architecture?
__init__.py is located at libs/core/langchain_core/outputs/__init__.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/langchain_core/outputs).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free