Fix:HTTPs component re.error: bad escape \u (#9480)
### What problem does this PR solve?
When calling HTTP to request data, if the JSON string returned by the
interface contains an unasked back slash like '\u', Python's RE module
will escape 'u' as Unicode, but there is no valid 4-digit hexadecimal
number at the end, so it will directly report an error. Error: re.
error: bad escape \ u at position 26
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Agent template: report agent using knowledge base (#9427)
### What problem does this PR solve?
Agent template: report agent using knowledge base
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Refa: Update LLM stream response type to Generator (#9420)
### What problem does this PR solve?
Change return type of _generate_streamly from str to Generator[str,
None, None] to properly type hint streaming responses.
### Type of change
- [x] Refactoring
Fix:valueERROR when file is optional but not exist value (#9414)
### What problem does this PR solve?
when begin component has optional file but not exist , it rase error
### Type of change
- [x] Bug Fix
Co-authored-by: Popmio <zhengyihao036@gamil.com>
Fix: Before executing the SQL, remove tags in the format [ID: number] to avoid execution errors. (#9326)
### What problem does this PR solve?
Before executing the SQL, remove tags in the format [ID: number] to
avoid execution errors.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Co-authored-by: wangyazhou <wangyazhou@sdibd.cn>
Fix:HTTP request component failed to retrieve the corresponding value (#9399)
### What problem does this PR solve?
https://github.com/infiniflow/ragflow/issues/9385
Based on my understanding, I think checking empty string is fine
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
---------
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
Agent plans tasks by referring to its own prompt. (#9315)
### What problem does this PR solve?
Fixes the issue in the analyze_task execution flow where the Lead Agent
was not utilizing its own sys_prompt during task analysis, resulting in
incorrect or incomplete task planning.
https://github.com/infiniflow/ragflow/issues/9294
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Fix: Replace StrEnum with strenum in code_exec.py (#9376)
### What problem does this PR solve?
- The enum import was changed from Python's built-in StrEnum to the
strenum package.
- Fix error `Warning: Failed to import module code_exec: cannot import
name 'StrEnum' from 'enum' (/usr/lib/python3.10/enum.py)`
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
New workflow templates: choose your knowledge base (#9325)
### What problem does this PR solve?
new Agent templates: you can choose your knowledge base, providing
workflow and Agent versions
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Add files viaContribute a new workflow template: SQL Assistant upload (#9311)
### What problem does this PR solve?
Contribute a new workflow template: SQL Assistant
### Type of change
- [x] Other (please describe): new workflow template
### What problem does this PR solve?
#9082#6365
<u> **WARNING: it's not compatible with the older version of `Agent`
module, which means that `Agent` from older versions can not work
anymore.**</u>
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Fix: code debug may corrupt by history answer (#8385)
### What problem does this PR solve?
Fix code debug may corrupt by history answer.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve?
Fix illegal variable name in Jinja2. #8316.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Fix: Update customer service template with query references to RewriteQuestion (#8252)
### What problem does this PR solve?
- Add query references to "RewriteQuestion:AllNightsSniff" in multiple
components
- Set "selected" to false for retrieval node
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve?
The issue of reporting the 「Can't inference the where the component
input is. Please identify whose output is this component's input」error
when creating an Agent using the Customer service template has been
resolved.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve?
now Streamning logic is not match with none streaming logic, which may
introduce down stream can not find upstream components.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve?
https://github.com/infiniflow/ragflow/issues/8006
The category should work well, but the category's downstream seems to be
unable to get the upstream output.
Add the category's output as an attribute.
However, in base.py, there is logic
` if self.component_name.lower().find("switch") < 0 and
self.get_component_name(u) in ["relevant", "categorize"]:
continue`
If goto this cases will not tried to get output from Category (but I do
not have full context about this if logic).
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve?
Fix code component debug issue. #7908.
I delete the additions in #7933, there is no semantic meaning `output`
for `parameters`.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Fix: add default output method for ComponentParamBase (#7933)
### What problem does this PR solve?
https://github.com/infiniflow/ragflow/issues/7908
For the code
` _, out = cpn.output(allow_partial=False)`
` def output(self, allow_partial=True) -> Tuple[str, Union[pd.DataFrame,
partial]]:
o = getattr(self._param, self._param.output_var_name)`
need to call this method
But I do not have a full context.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Fix:Setting the message_history_window_size to 0 does not take effect (#7842)
### What problem does this PR solve?
Close #7830
The caller method should already have code to handle this.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve?
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Co-authored-by: xiaohzho <xiaohzho@cisco.com>
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:

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

### 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>
### What problem does this PR solve?
Add code agent component.
#4977
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Feat: Support knowledge base type input in agent flow debugger (#7471)
### What problem does this PR solve?
This is a follow-up of #7088 , adding a knowledge base type input to the
`Begin` component, and a knowledge base selector to the agent flow debug
input panel:

then you can select one or more knowledge bases when testing the agent:

Note: the lines changed in `agent/component/retrieval.py` after line 94
are modified by `ruff format` from the `pre-commit` hooks, no functional
change.
### 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):
fixed errror when vars of cnt begin declare with key contain "begin" (#7457)
### What problem does this PR solve?
fixed errror when vars of cnt begin declare with key contain "begin"
_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Feat: Support passing knowledge base id as variable in retrieval component (#7088)
### What problem does this PR solve?
Fix #6600
Hello, I have the same business requirement as #6600. My use case is:
We have many departments (> 20 now and increasing), and each department
has its own knowledge base. Because the agent workflow is the same, so I
want to change the knowledge base on the fly, instead of creating agents
for every department.
It now looks like this:

Knowledge bases can be selected from the dropdown, and passed through
the variables in the table. All selected knowledge bases are used for
retrieval.
### 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):
### What problem does this PR solve?
Some models force thinking, resulting in the absence of the think tag in
the returned content
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)