mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Add component 'Template' (#3562)
### What problem does this PR solve? #3560 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -30,6 +30,7 @@ from .tushare import TuShare, TuShareParam
|
||||
from .akshare import AkShare, AkShareParam
|
||||
from .crawler import Crawler, CrawlerParam
|
||||
from .invoke import Invoke, InvokeParam
|
||||
from .template import Template, TemplateParam
|
||||
|
||||
|
||||
def component_class(class_name):
|
||||
|
||||
@ -145,7 +145,7 @@ class Generate(ComponentBase):
|
||||
else: retrieval_res = pd.DataFrame([])
|
||||
|
||||
for n, v in kwargs.items():
|
||||
prompt = re.sub(r"\{%s\}" % re.escape(n), re.escape(str(v)), prompt)
|
||||
prompt = re.sub(r"\{%s\}" % re.escape(n), str(v), prompt)
|
||||
|
||||
if not self._param.inputs and prompt.find("{input}") >= 0:
|
||||
retrieval_res = self.get_input()
|
||||
|
||||
@ -79,7 +79,7 @@ class Template(ComponentBase):
|
||||
self._param.inputs.append({"component_id": para["component_id"], "content": kwargs[para["key"]]})
|
||||
|
||||
for n, v in kwargs.items():
|
||||
content = re.sub(r"\{%s\}" % re.escape(n), re.escape(str(v)), content)
|
||||
content = re.sub(r"\{%s\}" % re.escape(n), str(v), content)
|
||||
|
||||
return Template.be_output(content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user