Support iframe chatbot. (#3961)

### What problem does this PR solve?

#3909

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Kevin Hu
2024-12-10 17:03:24 +08:00
committed by GitHub
parent 601d74160b
commit e9b8c30a38
9 changed files with 173 additions and 141 deletions

View File

@ -476,7 +476,7 @@ class ComponentBase(ABC):
self._param.inputs.append({"component_id": q["component_id"],
"content": "\n".join(
[str(d["content"]) for d in outs[-1].to_dict('records')])})
elif q["value"]:
elif q.get("value"):
self._param.inputs.append({"component_id": None, "content": q["value"]})
outs.append(pd.DataFrame([{"content": q["value"]}]))
if outs:
@ -526,6 +526,21 @@ class ComponentBase(ABC):
return df
def get_input_elements(self):
assert self._param.query, "Please identify input parameters firstly."
eles = []
for q in self._param.query:
if q.get("component_id"):
if q["component_id"].split("@")[0].lower().find("begin") >= 0:
cpn_id, key = q["component_id"].split("@")
eles.extend(self._canvas.get_component(cpn_id)["obj"]._param.query)
continue
eles.append({"key": q["key"], "component_id": q["component_id"]})
else:
eles.append({"key": q["key"]})
return eles
def get_stream_input(self):
reversed_cpnts = []
if len(self._canvas.path) > 1: