ragflow/web
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
..
.husky feat: format code before submitting it #1251 (#1252) 2024-06-24 14:48:21 +08:00
public 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
src Feat: Support tool calling in Generate component (#7572) 2025-05-16 16:32:19 +08:00
.env feat: Support for conversational streaming (#809) 2024-05-16 20:15:02 +08:00
.eslintrc.js feat: set chunk to available state and select all chunk (#57) 2024-02-06 18:45:20 +08:00
.gitignore Format file format from Windows/dos to Unix (#1949) 2024-08-15 09:17:36 +08:00
.npmrc Fix: Limit node version #3547 (#3563) 2024-11-21 18:14:22 +08:00
.prettierignore feat: install prettier to format code and add react-dev-inspector to locate code in the IDE faster (#44) 2024-01-29 15:02:27 +08:00
.prettierrc Feat: Add background to next login page #3221 (#4474) 2025-01-14 13:43:18 +08:00
.umirc.ts Feat: Add VariablePickerMenuPlugin to select variables in the prompt text box by menu #4764 (#4765) 2025-02-08 18:09:13 +08:00
externals.d.ts fix: cannot save the system model setting #468 (#508) 2024-04-23 17:46:56 +08:00
jest-setup.ts feat: test buildNodesAndEdgesFromDSLComponents (#940) 2024-05-27 19:35:14 +08:00
jest.config.ts feat: test buildNodesAndEdgesFromDSLComponents (#940) 2024-05-27 19:35:14 +08:00
package-lock.json 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
package.json 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
tailwind.config.js Feat: Modify the style of the dataset page #3221 (#7446) 2025-05-02 21:27:21 +08:00
tailwind.css Feat: Modify the style of the dataset page #3221 (#7446) 2025-05-02 21:27:21 +08:00
tsconfig.json feat: Configure the root directory alias #1739 (#2875) 2024-10-17 11:36:01 +08:00
typings.d.ts Feat: Add FilesTable #3221 (#4491) 2025-01-15 14:39:33 +08:00