functions() — langchain Function Reference
Architecture documentation for the functions() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a401586c_3e20_a72a_c862_b29ba9695ced["functions()"] 4079b11a_3240_0a70_5830_e3af3b13b06e["OpenAIMultiFunctionsAgent"] a401586c_3e20_a72a_c862_b29ba9695ced -->|defined in| 4079b11a_3240_0a70_5830_e3af3b13b06e style a401586c_3e20_a72a_c862_b29ba9695ced fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py lines 144–202
def functions(self) -> list[dict]:
"""Get the functions for the agent."""
enum_vals = [t.name for t in self.tools]
tool_selection = {
# OpenAI functions returns a single tool invocation
# Here we force the single tool invocation it returns to
# itself be a list of tool invocations. We do this by constructing
# a new tool that has one argument which is a list of tools
# to use.
"name": "tool_selection",
"description": "A list of actions to take.",
"parameters": {
"title": "tool_selection",
"description": "A list of actions to take.",
"type": "object",
"properties": {
"actions": {
"title": "actions",
"type": "array",
"items": {
# This is a custom item which bundles the action_name
# and the action. We do this because some actions
# could have the same schema, and without this there
# is no way to differentiate them.
"title": "tool_call",
"type": "object",
"properties": {
# This is the name of the action to take
"action_name": {
"title": "action_name",
"enum": enum_vals,
"type": "string",
"description": (
"Name of the action to take. The name "
"provided here should match up with the "
"parameters for the action below."
),
},
# This is the action to take.
"action": {
"title": "Action",
"anyOf": [
{
"title": t.name,
"type": "object",
"properties": t.args,
}
for t in self.tools
],
},
},
"required": ["action_name", "action"],
},
},
},
"required": ["actions"],
},
}
return [tool_selection]
Domain
Subdomains
Source
Frequently Asked Questions
What does functions() do?
functions() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py.
Where is functions() defined?
functions() is defined in libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py at line 144.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free