ragflow/web/src/utils
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
..
api.ts Feat: Support tool calling in Generate component (#7572) 2025-05-16 16:32:19 +08:00
authorization-util.ts Feat: If the user is not logged in, jump to the login page by refreshing. (#5451) 2025-02-27 18:48:53 +08:00
chat.ts Feat: Display inline (non-quoted) images in the chat and search modules #7623 (#7638) 2025-05-14 15:44:54 +08:00
common-util.ts Feat: Support vLLM #4316 (#5395) 2025-02-26 18:33:43 +08:00
dataset-util.ts Feat: Filter document by running status and file type. #3221 (#7340) 2025-04-27 14:39:05 +08:00
date.ts Feat: Add ChatCard #3221 (#4852) 2025-02-10 17:38:10 +08:00
document-util.ts
dom-util.ts
file-util.ts Feat: Support preview of HTML files #5096 (#5134) 2025-02-19 16:28:48 +08:00
form.ts
index.ts
llm-util.ts Feat: Hide the suffix of the large model name. #5433 (#5494) 2025-02-28 18:02:33 +08:00
register-server.ts
request.ts Feat: If the user is not logged in, jump to the login page by refreshing. (#5451) 2025-02-27 18:48:53 +08:00
store-util.ts