fix bugs about multi input for generate (#1525)

### What problem does this PR solve?



### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu 2024-07-16 09:28:13 +08:00 committed by GitHub
parent d4332643c4
commit 2a647162a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -193,9 +193,13 @@ class Canvas(ABC):
self.answer.append(c)
else:
if DEBUG: print("RUN: ", c)
if cpn.component_name == "Generate":
cpids = cpn.get_dependent_components()
if any([c not in self.path[-1] for c in cpids]):
continue
ans = cpn.run(self.history, **kwargs)
self.path[-1].append(c)
ran += 1
ran += 1
prepare2run(self.components[self.path[-2][-1]]["downstream"])
while 0 <= ran < len(self.path[-1]):

View File

@ -445,6 +445,7 @@ class ComponentBase(ABC):
if DEBUG: print(self.component_name, reversed_cpnts[::-1])
for u in reversed_cpnts[::-1]:
if self.get_component_name(u) in ["switch"]: continue
if u not in self._canvas.get_component(self._id)["upstream"]: continue
if self.component_name.lower().find("switch") < 0 \
and self.get_component_name(u) in ["relevant", "categorize"]:
continue

View File

@ -63,6 +63,10 @@ class GenerateParam(ComponentParamBase):
class Generate(ComponentBase):
component_name = "Generate"
def get_dependent_components(self):
cpnts = [para["component_id"] for para in self._param.parameters]
return cpnts
def _run(self, history, **kwargs):
chat_mdl = LLMBundle(self._canvas.get_tenant_id(), LLMType.CHAT, self._param.llm_id)
prompt = self._param.prompt