Fix agent session API (#3589)

### What problem does this PR solve?

#3585
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu
2024-11-22 16:19:00 +08:00
committed by GitHub
parent ee33bf71eb
commit cc219ff648
14 changed files with 36 additions and 94 deletions

View File

@ -390,8 +390,8 @@ class ComponentBase(ABC):
"inputs": {}
}}""".format(self.component_name,
self._param,
json.dumps(json.loads(str(self._param))["output"], ensure_ascii=False),
json.dumps(json.loads(str(self._param))["inputs"], ensure_ascii=False)
json.dumps(json.loads(str(self._param)).get("output", {}), ensure_ascii=False),
json.dumps(json.loads(str(self._param)).get("inputs", []), ensure_ascii=False)
)
def __init__(self, canvas, id, param: ComponentParamBase):

View File

@ -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), str(v), prompt)
prompt = re.sub(r"\{%s\}" % re.escape(n), str(v).replace("\\", " "), prompt)
if not self._param.inputs and prompt.find("{input}") >= 0:
retrieval_res = self.get_input()

View File

@ -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), str(v), content)
content = re.sub(r"\{%s\}" % re.escape(n), str(v).replace("\\", " "), content)
return Template.be_output(content)