Skip to content

Commit

Permalink
Fix agent session API
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHuSh committed Nov 22, 2024
1 parent ee7fd71 commit 06c104f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 72 deletions.
4 changes: 2 additions & 2 deletions agent/component/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ def __str__(self):
"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):
Expand Down
2 changes: 1 addition & 1 deletion agent/component/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _run(self, history, **kwargs):
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()
Expand Down
2 changes: 1 addition & 1 deletion agent/component/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _run(self, history, **kwargs):
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)

Loading

0 comments on commit 06c104f

Please sign in to comment.