experimental.py — langchain Source File
Architecture documentation for experimental.py, a python file in the langchain codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 21cb062e_69ff_8301_3be0_f16b3b495da7["experimental.py"] 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] 21cb062e_69ff_8301_3be0_f16b3b495da7 --> 7025b240_fdc3_cf68_b72f_f41dac94566b 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 21cb062e_69ff_8301_3be0_f16b3b495da7 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 style 21cb062e_69ff_8301_3be0_f16b3b495da7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Experimental tool-calling support for Anthropic chat models."""
from __future__ import annotations
import json
from typing import (
Any,
)
SYSTEM_PROMPT_FORMAT = """In this environment you have access to a set of tools you can use to answer the user's question.
You may call them like this:
<function_calls>
<invoke>
<tool_name>$TOOL_NAME</tool_name>
<parameters>
<$PARAMETER_NAME>$PARAMETER_VALUE</$PARAMETER_NAME>
...
</parameters>
</invoke>
</function_calls>
Here are the tools available:
<tools>
{formatted_tools}
</tools>""" # noqa: E501
TOOL_FORMAT = """<tool_description>
<tool_name>{tool_name}</tool_name>
<description>{tool_description}</description>
<parameters>
{formatted_parameters}
</parameters>
</tool_description>"""
TOOL_PARAMETER_FORMAT = """<parameter>
<name>{parameter_name}</name>
<type>{parameter_type}</type>
<description>{parameter_description}</description>
</parameter>"""
def _get_type(parameter: dict[str, Any]) -> str:
if "type" in parameter:
return parameter["type"]
if "anyOf" in parameter:
return json.dumps({"anyOf": parameter["anyOf"]})
if "allOf" in parameter:
return json.dumps({"allOf": parameter["allOf"]})
return json.dumps(parameter)
def get_system_message(tools: list[dict]) -> str:
"""Generate a system message that describes the available tools."""
tools_data: list[dict] = [
{
"tool_name": tool["name"],
"tool_description": tool["description"],
"formatted_parameters": "\n".join(
[
// ... (81 more lines)
Domain
Subdomains
Dependencies
- json
- typing
Source
Frequently Asked Questions
What does experimental.py do?
experimental.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 experimental.py?
experimental.py defines 5 function(s): _get_type, _xml_to_dict, _xml_to_function_call, _xml_to_tool_calls, get_system_message.
What does experimental.py depend on?
experimental.py imports 2 module(s): json, typing.
Where is experimental.py in the architecture?
experimental.py is located at libs/partners/anthropic/langchain_anthropic/experimental.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/partners/anthropic/langchain_anthropic).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free