stdout.py — langchain Source File
Architecture documentation for stdout.py, a python file in the langchain codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR df2d25a2_3482_fb65_cc35_43b648e7bc5a["stdout.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] df2d25a2_3482_fb65_cc35_43b648e7bc5a --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] df2d25a2_3482_fb65_cc35_43b648e7bc5a --> 91721f45_4909_e489_8c1f_084f8bd87145 7e64d143_ea36_1c73_4897_1d0ae1757b5b["langchain_core.callbacks.base"] df2d25a2_3482_fb65_cc35_43b648e7bc5a --> 7e64d143_ea36_1c73_4897_1d0ae1757b5b f4d905c6_a2b2_eb8f_be9b_7808b72f6a16["langchain_core.utils"] df2d25a2_3482_fb65_cc35_43b648e7bc5a --> f4d905c6_a2b2_eb8f_be9b_7808b72f6a16 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"] df2d25a2_3482_fb65_cc35_43b648e7bc5a --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b style df2d25a2_3482_fb65_cc35_43b648e7bc5a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Callback handler that prints to std out."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing_extensions import override
from langchain_core.callbacks.base import BaseCallbackHandler
from langchain_core.utils import print_text
if TYPE_CHECKING:
from langchain_core.agents import AgentAction, AgentFinish
class StdOutCallbackHandler(BaseCallbackHandler):
"""Callback handler that prints to std out."""
def __init__(self, color: str | None = None) -> None:
"""Initialize callback handler.
Args:
color: The color to use for the text.
"""
self.color = color
@override
def on_chain_start(
self, serialized: dict[str, Any], inputs: dict[str, Any], **kwargs: Any
) -> None:
"""Print out that we are entering a chain.
Args:
serialized: The serialized chain.
inputs: The inputs to the chain.
**kwargs: Additional keyword arguments.
"""
if "name" in kwargs:
name = kwargs["name"]
elif serialized:
name = serialized.get("name", serialized.get("id", ["<unknown>"])[-1])
else:
name = "<unknown>"
print(f"\n\n\033[1m> Entering new {name} chain...\033[0m") # noqa: T201
@override
def on_chain_end(self, outputs: dict[str, Any], **kwargs: Any) -> None:
"""Print out that we finished a chain.
Args:
outputs: The outputs of the chain.
**kwargs: Additional keyword arguments.
"""
print("\n\033[1m> Finished chain.\033[0m") # noqa: T201
@override
def on_agent_action(
self, action: AgentAction, color: str | None = None, **kwargs: Any
) -> Any:
"""Run on agent action.
// ... (64 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- langchain_core.agents
- langchain_core.callbacks.base
- langchain_core.utils
- typing
- typing_extensions
Source
Frequently Asked Questions
What does stdout.py do?
stdout.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 stdout.py?
stdout.py defines 1 function(s): langchain_core.
What does stdout.py depend on?
stdout.py imports 5 module(s): langchain_core.agents, langchain_core.callbacks.base, langchain_core.utils, typing, typing_extensions.
Where is stdout.py in the architecture?
stdout.py is located at libs/core/langchain_core/callbacks/stdout.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/langchain_core/callbacks).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free