ragflow/api/db/services
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
..
__init__.py Fix errors detected by Ruff (#3918) 2024-12-08 14:21:12 +08:00
api_service.py Feat(api): Add dsl parameters to control whether dsl fields are included (#5769) 2025-03-07 16:58:00 +08:00
canvas_service.py Feat: add OpenAI compatible API for agent (#6329) 2025-04-03 16:51:37 +08:00
common_service.py Perf: Increase database connection pool size (#7559) 2025-05-09 17:52:03 +08:00
conversation_service.py Fix issue of ask API. (#5400) 2025-02-26 19:45:22 +08:00
dialog_service.py Feat: support cross-lang search. (#7557) 2025-05-09 15:32:02 +08:00
document_service.py Feat: support cross-lang search. (#7557) 2025-05-09 15:32:02 +08:00
file2document_service.py Tagging (#4426) 2025-01-09 17:07:21 +08:00
file_service.py Fix: file name length limit mismtach (#7630) 2025-05-14 10:13:03 +08:00
knowledgebase_service.py Fix: filed_map was incorrectly persisted (#7443) 2025-05-06 09:44:38 +08:00
langfuse_service.py Feat: add Langfuse APIs (#6460) 2025-03-24 18:25:43 +08:00
llm_service.py Feat: Support tool calling in Generate component (#7572) 2025-05-16 16:32:19 +08:00
task_service.py Introduced task priority (#6118) 2025-03-14 23:43:46 +08:00
user_canvas_version.py Feat: Improve 'user_canvan_version' delete and 'document' delete performance (#6553) 2025-05-07 10:55:08 +08:00
user_service.py Refa. (#7022) 2025-04-15 10:20:33 +08:00