Browse Source

fix issue wrong agent prologue for api (#2246)

### What problem does this PR solve?

#2242
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.11.0
Kevin Hu 1 year ago
parent
commit
02fb7a88e3
No account linked to committer's email address
2 changed files with 10 additions and 4 deletions
  1. 4
    1
      agent/canvas.py
  2. 6
    3
      api/apps/api_app.py

+ 4
- 1
agent/canvas.py View File

pat = " => ".join([p.split(":")[0] for p in path[0:l]]) pat = " => ".join([p.split(":")[0] for p in path[0:l]])
return pat + " => " + pat return pat + " => " + pat


return False
return

def get_prologue(self):
return self.components["begin"]["obj"]._param.prologue

+ 6
- 3
api/apps/api_app.py View File

req = request.json req = request.json
try: try:
if objs[0].source == "agent": if objs[0].source == "agent":
e, c = UserCanvasService.get_by_id(objs[0].dialog_id)
e, cvs = UserCanvasService.get_by_id(objs[0].dialog_id)
if not e: if not e:
return server_error_response("canvas not found.") return server_error_response("canvas not found.")
if not isinstance(cvs.dsl, str):
cvs.dsl = json.dumps(cvs.dsl, ensure_ascii=False)
canvas = Canvas(cvs.dsl, objs[0].tenant_id)
conv = { conv = {
"id": get_uuid(), "id": get_uuid(),
"dialog_id": c.id,
"dialog_id": cvs.id,
"user_id": request.args.get("user_id", ""), "user_id": request.args.get("user_id", ""),
"message": [{"role": "assistant", "content": "Hi there!"}],
"message": [{"role": "assistant", "content": canvas.get_prologue()}],
"source": "agent" "source": "agent"
} }
API4ConversationService.save(**conv) API4ConversationService.save(**conv)

Loading…
Cancel
Save