fix generate error (#1590)

### What problem does this PR solve?

#1550 #1210 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu
2024-07-18 14:33:30 +08:00
committed by GitHub
parent 4da3ee400b
commit 2b5812d0a9
4 changed files with 10 additions and 6 deletions

View File

@ -86,7 +86,10 @@ class Generate(ComponentBase):
# prompt = re.sub(r"\{%s\}"%n, re.escape(str(v)), prompt)
prompt = re.sub(r"\{%s\}" % n, str(v), prompt)
if kwargs.get("stream"):
downstreams = self._canvas.get_component(self._id)["downstream"]
if kwargs.get("stream") \
and len(downstreams) == 1 \
and self._canvas.get_component(downstreams[0])["obj"].component_name.lower() == "answer":
return partial(self.stream_output, chat_mdl, prompt, retrieval_res)
if "empty_response" in retrieval_res.columns: