Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve tool text description and args #1512

Merged
merged 4 commits into from
Oct 25, 2024

Conversation

bhancockio
Copy link
Collaborator

@bhancockio bhancockio commented Oct 25, 2024

Simplify tools for LLMs to better understand what they need to pass to tools.

Before

Tool Name: Read website content(**kwargs: Any) -> Any
Tool Description: Read website content(website_url: 'string') - A tool that can be used to read a website content. website_url: 'Mandatory website url to read the file'
Tool Arguments: {'name': FieldInfo(annotation=str, required=True), 'description': FieldInfo(annotation=str, required=False, default=''), 'args_schema': FieldInfo(annotation=type[BaseModel], required=True, description='The tool schema.', metadata=[SkipValidation()]), 'return_direct': FieldInfo(annotation=bool, required=False, default=False), 'verbose': FieldInfo(annotation=bool, required=False, default=False), 'callbacks': FieldInfo(annotation=Union[list[BaseCallbackHandler], BaseCallbackManager, NoneType], required=False, default=None, exclude=True), 'callback_manager': FieldInfo(annotation=Union[BaseCallbackManager, NoneType], required=False, default=None, description='.. deprecated:: 0.1.7 Use :meth:`~callbacks` instead.\n\nCallback manager to add to the run trace.', exclude=True), 'tags': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=None), 'metadata': FieldInfo(annotation=Union[dict[str, Any], NoneType], required=False, default=None), 'handle_tool_error': FieldInfo(annotation=Union[bool, str, Callable[list, str], NoneType], required=False, default=False), 'handle_validation_error': FieldInfo(annotation=Union[bool, str, Callable[list, str], NoneType], required=False, default=False), 'response_format': FieldInfo(annotation=Literal['content', 'content_and_artifact'], required=False, default='content'), 'func': FieldInfo(annotation=Union[Callable[..., Any], NoneType], required=False, default=None), 'coroutine': FieldInfo(annotation=Union[Callable[..., Awaitable[Any]], NoneType], required=False, default=None)}
Tool Name: Search the internet(**kwargs: Any) -> Any
Tool Description: Search the internet(search_query: 'string') - A tool that can be used to search the internet with a search_query. search_query: 'Mandatory search query you want to use to search the internet'
Tool Arguments: {'name': FieldInfo(annotation=str, required=True), 'description': FieldInfo(annotation=str, required=False, default=''), 'args_schema': FieldInfo(annotation=type[BaseModel], required=True, description='The tool schema.', metadata=[SkipValidation()]), 'return_direct': FieldInfo(annotation=bool, required=False, default=False), 'verbose': FieldInfo(annotation=bool, required=False, default=False), 'callbacks': FieldInfo(annotation=Union[list[BaseCallbackHandler], BaseCallbackManager, NoneType], required=False, default=None, exclude=True), 'callback_manager': FieldInfo(annotation=Union[BaseCallbackManager, NoneType], required=False, default=None, description='.. deprecated:: 0.1.7 Use :meth:`~callbacks` instead.\n\nCallback manager to add to the run trace.', exclude=True), 'tags': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=None), 'metadata': FieldInfo(annotation=Union[dict[str, Any], NoneType], required=False, default=None), 'handle_tool_error': FieldInfo(annotation=Union[bool, str, Callable[list, str], NoneType], required=False, default=False), 'handle_validation_error': FieldInfo(annotation=Union[bool, str, Callable[list, str], NoneType], required=False, default=False), 'response_format': FieldInfo(annotation=Literal['content', 'content_and_artifact'], required=False, default='content'), 'func': FieldInfo(annotation=Union[Callable[..., Any], NoneType], required=False, default=None), 'coroutine': FieldInfo(annotation=Union[Callable[..., Awaitable[Any]], NoneType], required=False, default=None)}

After

Tool Name: Search the internet
Tool Description: Search the internet(search_query: 'string') - A tool that can be used to search the internet with a search_query. search_query: 'Mandatory search query you want to use to search the internet'
Tool Arguments: {'search_query': {'description': 'Mandatory search query you want to use to search the internet', 'type': 'str'}}
Tool Name: Read website content
Tool Description: Read website content(website_url: 'string') - A tool that can be used to read a website content. website_url: 'Mandatory website url to read the file'
Tool Arguments: {'website_url': {'description': 'Mandatory website url to read the file', 'type': 'str'}}

Closes #1511

Thank you @c0dezli

Copy link
Collaborator

@lorenzejay lorenzejay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpler and cleaner! Awesome work!

@bhancockio bhancockio merged commit 26afee9 into main Oct 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] fix: Improve tool description generation in Agent class for better LLM comprehension
2 participants