llm icon indicating copy to clipboard operation
llm copied to clipboard

Support adding `!tool`s in chat

Open daturkel opened this issue 7 months ago • 1 comments

(mostly copilot-generated pr description)

This pull request introduces the ability to dynamically add tools to conversations using the !tool command, along with supporting functionality and documentation updates. The changes include updates to the CLI, new helper functions for processing and updating tools, and extensive documentation and testing enhancements.

For now, !tool can't support adding toolboxes due to https://github.com/simonw/llm/issues/1092 so it just logs an error to the user.

New Feature: Dynamic Tool Addition

  • Added the !tool command to allow users to dynamically add tools during conversations. This functionality is integrated into the chat CLI command. (llm/cli.py) [1] [2]
  • Implemented process_tools_in_chat and update_tools helper functions to handle parsing and updating tools in the conversation. (llm/cli.py)

Documentation Updates

  • Updated multiple documentation files (README.md, docs/fragments.md, docs/index.md, docs/plugins/plugin-hooks.md, docs/tools.md, docs/usage.md) to include details about the new !tool command. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Testing Enhancements

  • Added unit tests for process_tools_in_chat and update_tools functions to ensure proper parsing and deduplication of tools. (tests/test_chat.py)
  • Extended existing chat tests to validate the integration of the !tool command and its functionality. (tests/test_chat.py) [1] [2] [3] [4]
  • Introduced a new integration test for the !tool command to verify its behavior in real-world scenarios. (tests/test_chat.py)

daturkel avatar May 29 '25 03:05 daturkel

note: maybe there should be a click.echo confirmation to the user when a tool is successfully added to chat. ditto for !fragment honestly

daturkel avatar May 29 '25 04:05 daturkel

@simonw , bumping this, it should be good to merge?

daturkel avatar Jun 19 '25 14:06 daturkel