"Add description information for each input parameter of the Tool." #18776
dongfangduoshou123
announced in
Ideas
Replies: 1 comment
-
Found this link when googling whether it is available now or not. @tool
def multiply_by_max(
a: Annotated[int, "scale factor"],
b: Annotated[List[int], "list of ints over which to take maximum"],
) -> int:
"""Multiply a by the maximum of b."""
return a * max(b) {'description': 'Multiply a by the maximum of b.',
'properties': {'a': {'description': 'scale factor',
'title': 'A',
'type': 'string'},
'b': {'description': 'list of ints over which to take maximum',
'items': {'type': 'integer'},
'title': 'B',
'type': 'array'}},
'required': ['a', 'b'],
'title': 'multiply_by_maxSchema',
'type': 'object'} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
I suggest adding a parameter description attribute, similar to params_description: list[str], to the Tool module in LangChain for tool invocation. While there is already a description field that elaborates on the specific functionality of a tool, the absence of a description for the tool's input parameters means that while an agent can correctly identify which tool to use, it might struggle to accurately generate the necessary input parameters for the tool invocation. This idea was inspired by my exploration of the semantic-kernel library and its definition of kernel plugins (for example: https://github.com/microsoft/semantic-kernel/blob/main/python/semantic_kernel/core_plugins/http_plugin.py). In semantic-kernel, a plugin's description and the description of the plugin's input parameters are equally important. Including both the plugin's description and the input parameters' description in the prompt can assist an LLM in better matching the requirements for function inputs. Thus, if LangChain's tools also included information similar to params_description, we could incorporate the requirements for input parameters into the design of the agent's prompt, making the agent more effective and user-friendly.
Motivation
when the tool‘s input param-description is supported, we can add the param description of tool in the agent’s prompt text。
Proposal (If applicable)
like below code,we can use the Annotated
`
from typing import Annotated
@tool
def post_tool(
self,
url: Annotated[str, "The URI to send the request to."],
body: Annotated[Optional[Dict[str, Any]], "The body of the request"] = {},
) -> str:
"""
Sends an HTTP POST request to the specified URI and returns
the response body as a string.
params:
url: The URI to send the request to.
body: Contains the body of the request
returns:
The response body as a string.
"""`
Beta Was this translation helpful? Give feedback.
All reactions