Skip to content

Commit

Permalink
let 'Generate' take user's input as parameter (#3086)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

#3085

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
KevinHuSh authored Oct 29, 2024
1 parent 3ed096f commit f7705d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion agent/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def get_tenant_id(self):

def get_history(self, window_size):
convs = []
for role, obj in self.history[(window_size + 1) * -1:]:
for role, obj in self.history[window_size * -1:]:
convs.append({"role": role, "content": (obj if role == "user" else
'\n'.join([str(s) for s in pd.DataFrame(obj)['content']]))})
return convs
Expand Down
3 changes: 3 additions & 0 deletions agent/component/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def _run(self, history, **kwargs):
input = (" - "+"\n - ".join([c for c in retrieval_res["content"] if isinstance(c, str)])) if "content" in retrieval_res else ""
for para in self._param.parameters:
cpn = self._canvas.get_component(para["component_id"])["obj"]
if cpn.component_name.lower() == "answer":
kwargs[para["key"]] = self._canvas.get_history(1)[0]["content"]
continue
_, out = cpn.output(allow_partial=False)
if "content" not in out.columns:
kwargs[para["key"]] = "Nothing"
Expand Down

1 comment on commit f7705d6

@AlowprofileHacker
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

263 line 263 will cause User get every record in history if input is '0'

Please sign in to comment.