ragflow/api/apps
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
..
auth Docs: Improve oauth configuration documentation and examples (#7675) 2025-05-16 14:17:39 +08:00
sdk Fix:Fail to get list_sessions (#7678) 2025-05-16 10:58:28 +08:00
__init__.py Refa: enlarge default max request body size. (#6088) 2025-03-14 15:21:08 +08:00
api_app.py FIX:ZeroDivisionError when using large page_size in client.retrieve() (#7595) 2025-05-13 10:46:31 +08:00
canvas_app.py Fix:Agent running message i10n (#7635) 2025-05-14 14:27:12 +08:00
chunk_app.py Feat: When Delete Chunk Will Also Delete Chunk Related Image (#7656) 2025-05-15 11:53:47 +08:00
conversation_app.py Trival. (#7653) 2025-05-15 11:03:05 +08:00
dialog_app.py Support chat solo. (#5218) 2025-02-21 12:24:02 +08:00
document_app.py Fix: filed_map was incorrectly persisted (#7443) 2025-05-06 09:44:38 +08:00
file2document_app.py Fix: link to KB from filemanager. (#6530) 2025-03-26 09:41:14 +08:00
file_app.py fix: After the file is deleted, it still remains in the bucket. (#7482) 2025-05-06 19:30:42 +08:00
kb_app.py Feat: KB detail supports document total size (#7546) 2025-05-09 11:48:54 +08:00
langfuse_app.py Feat: add project_id and project_name to Langfuse API (#6481) 2025-03-25 10:36:34 +08:00
llm_app.py Fix: Hunyuan model adding error. (#6531) 2025-03-26 10:33:33 +08:00
plugin_app.py Feat: Support tool calling in Generate component (#7572) 2025-05-16 16:32:19 +08:00
system_app.py Feat: Add user registration toggle feature (#6327) 2025-03-21 09:38:15 +08:00
tenant_app.py Update team invite message (#4085) 2024-12-18 14:20:09 +08:00
user_app.py Refa: Deprecate /github_callback in favor of /oauth/callback/<channel> for GitHub OAuth integration (#7587) 2025-05-15 14:39:37 +08:00