schema.py — langchain Source File
Architecture documentation for schema.py, a python file in the langchain codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c5a5326d_2157_aedd_8829_30e2b51eaa85["schema.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] c5a5326d_2157_aedd_8829_30e2b51eaa85 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"] c5a5326d_2157_aedd_8829_30e2b51eaa85 --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b e45722a2_0136_a972_1f58_7b5987500404["langchain_core.prompts.chat"] c5a5326d_2157_aedd_8829_30e2b51eaa85 --> e45722a2_0136_a972_1f58_7b5987500404 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] c5a5326d_2157_aedd_8829_30e2b51eaa85 --> 91721f45_4909_e489_8c1f_084f8bd87145 style c5a5326d_2157_aedd_8829_30e2b51eaa85 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Any
from langchain_core.agents import AgentAction
from langchain_core.prompts.chat import ChatPromptTemplate
from typing_extensions import override
class AgentScratchPadChatPromptTemplate(ChatPromptTemplate):
"""Chat prompt template for the agent scratchpad."""
@classmethod
@override
def is_lc_serializable(cls) -> bool:
return False
def _construct_agent_scratchpad(
self,
intermediate_steps: list[tuple[AgentAction, str]],
) -> str:
if len(intermediate_steps) == 0:
return ""
thoughts = ""
for action, observation in intermediate_steps:
thoughts += action.log
thoughts += f"\nObservation: {observation}\nThought: "
return (
f"This was your previous work "
f"(but I haven't seen any of it! I only see what "
f"you return as final answer):\n{thoughts}"
)
def _merge_partial_and_user_variables(self, **kwargs: Any) -> dict[str, Any]:
intermediate_steps = kwargs.pop("intermediate_steps")
kwargs["agent_scratchpad"] = self._construct_agent_scratchpad(
intermediate_steps,
)
return kwargs
Domain
Subdomains
Dependencies
- langchain_core.agents
- langchain_core.prompts.chat
- typing
- typing_extensions
Source
Frequently Asked Questions
What does schema.py do?
schema.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, ToolInterface subdomain.
What does schema.py depend on?
schema.py imports 4 module(s): langchain_core.agents, langchain_core.prompts.chat, typing, typing_extensions.
Where is schema.py in the architecture?
schema.py is located at libs/langchain/langchain_classic/agents/schema.py (domain: AgentOrchestration, subdomain: ToolInterface, directory: libs/langchain/langchain_classic/agents).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free