ragflow/web/src/hooks
Song Fuchang a1f06a4fdc
Feat: Support tool calling in Generate component (#7572)
### What problem does this PR solve?

Hello, our use case requires LLM agent to invoke some tools, so I made a
simple implementation here.

This PR does two things:

1. A simple plugin mechanism based on `pluginlib`:

This mechanism lives in the `plugin` directory. It will only load
plugins from `plugin/embedded_plugins` for now.

A sample plugin `bad_calculator.py` is placed in
`plugin/embedded_plugins/llm_tools`, it accepts two numbers `a` and `b`,
then give a wrong result `a + b + 100`.

In the future, it can load plugins from external location with little
code change.

Plugins are divided into different types. The only plugin type supported
in this PR is `llm_tools`, which must implement the `LLMToolPlugin`
class in the `plugin/llm_tool_plugin.py`.
More plugin types can be added in the future.

2. A tool selector in the `Generate` component:

Added a tool selector to select one or more tools for LLM:


![image](https://github.com/user-attachments/assets/74a21fdf-9333-4175-991b-43df6524c5dc)

And with the `bad_calculator` tool, it results this with the `qwen-max`
model:


![image](https://github.com/user-attachments/assets/93aff9c4-8550-414a-90a2-1a15a5249d94)


### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):

Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com>
2025-05-16 16:32:19 +08:00
..
logic-hooks Feat: Adjust the operation cell of the table on the file management page and dataset page #3221. (#7526) 2025-05-08 15:25:26 +08:00
auth-hooks.ts Feat: Add frontend support for third-party login integration (#7553) 2025-05-14 12:19:28 +08:00
chat-hooks.ts Feat: Load the dialog page, prohibit calling the dialog/get interface #6798 (#6799) 2025-04-03 18:04:40 +08:00
chunk-hooks.ts Feat: Display the knowledge graph on the knowledge base page #4543 (#4587) 2025-01-22 19:43:27 +08:00
common-hooks.tsx Feat: Display the knowledge graph on the knowledge base page #4543 (#4587) 2025-01-22 19:43:27 +08:00
document-hooks.ts Feat: Filter document by running status and file type. #3221 (#7340) 2025-04-27 14:39:05 +08:00
file-manager-hooks.ts Fix: Delete unused code #3651 (#3852) 2024-12-04 14:15:17 +08:00
flow-hooks.ts Feat: add agent share team viewer (#6222) 2025-03-19 19:04:13 +08:00
knowledge-hooks.ts Put the knowledge base list related hooks into use-knowledge-request.ts #3221 (#7197) 2025-04-22 15:01:35 +08:00
llm-hooks.tsx Feat: Support tool calling in Generate component (#7572) 2025-05-16 16:32:19 +08:00
logic-hooks.ts Feat: Interrupt streaming #6515 (#6723) 2025-04-01 17:26:54 +08:00
login-hooks.ts Feat: Add frontend support for third-party login integration (#7553) 2025-05-14 12:19:28 +08:00
plugin-hooks.tsx Feat: Support tool calling in Generate component (#7572) 2025-05-16 16:32:19 +08:00
route-hook.ts fix: remove unused libraries #1306 (#1649) 2024-07-23 15:03:58 +08:00
system-hooks.ts Feat: Add user registration toggle feature (#6327) 2025-03-21 09:38:15 +08:00
use-agent-request.ts Feat: Bind data to the agent module of the home page #3221 (#7385) 2025-04-29 09:50:54 +08:00
use-callback-ref.ts Feat: Add FileUploadDialog #3221 (#4327) 2025-01-02 16:10:41 +08:00
use-chat-request.ts Feat: Fixed the issue where the chat page would jump after entering the homepage #3221 (#7616) 2025-05-13 17:57:28 +08:00
use-controllable-state.ts Feat: Add FileUploadDialog #3221 (#4327) 2025-01-02 16:10:41 +08:00
use-document-request.ts Feat: Adjust the operation cell of the table on the file management page and dataset page #3221. (#7526) 2025-05-08 15:25:26 +08:00
use-file-request.ts Feat: Deleting files in batches. #3221 (#7234) 2025-04-23 19:03:02 +08:00
use-knowledge-request.ts Feat: Filter document by running status and file type. #3221 (#7340) 2025-04-27 14:39:05 +08:00
user-setting-hooks.tsx Feat: Add LangfuseCard component. #6155 (#6468) 2025-03-24 19:07:55 +08:00