Kevin Hu
commited on
Commit
·
61acd39
1
Parent(s):
4740a3f
fix issue wrong agent prologue for api (#2246)
Browse files### What problem does this PR solve?
#2242
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- agent/canvas.py +4 -1
- api/apps/api_app.py +6 -3
agent/canvas.py
CHANGED
@@ -299,4 +299,7 @@ class Canvas(ABC):
|
|
299 |
pat = " => ".join([p.split(":")[0] for p in path[0:l]])
|
300 |
return pat + " => " + pat
|
301 |
|
302 |
-
return
|
|
|
|
|
|
|
|
299 |
pat = " => ".join([p.split(":")[0] for p in path[0:l]])
|
300 |
return pat + " => " + pat
|
301 |
|
302 |
+
return
|
303 |
+
|
304 |
+
def get_prologue(self):
|
305 |
+
return self.components["begin"]["obj"]._param.prologue
|
api/apps/api_app.py
CHANGED
@@ -151,14 +151,17 @@ def set_conversation():
|
|
151 |
req = request.json
|
152 |
try:
|
153 |
if objs[0].source == "agent":
|
154 |
-
e,
|
155 |
if not e:
|
156 |
return server_error_response("canvas not found.")
|
|
|
|
|
|
|
157 |
conv = {
|
158 |
"id": get_uuid(),
|
159 |
-
"dialog_id":
|
160 |
"user_id": request.args.get("user_id", ""),
|
161 |
-
"message": [{"role": "assistant", "content":
|
162 |
"source": "agent"
|
163 |
}
|
164 |
API4ConversationService.save(**conv)
|
|
|
151 |
req = request.json
|
152 |
try:
|
153 |
if objs[0].source == "agent":
|
154 |
+
e, cvs = UserCanvasService.get_by_id(objs[0].dialog_id)
|
155 |
if not e:
|
156 |
return server_error_response("canvas not found.")
|
157 |
+
if not isinstance(cvs.dsl, str):
|
158 |
+
cvs.dsl = json.dumps(cvs.dsl, ensure_ascii=False)
|
159 |
+
canvas = Canvas(cvs.dsl, objs[0].tenant_id)
|
160 |
conv = {
|
161 |
"id": get_uuid(),
|
162 |
+
"dialog_id": cvs.id,
|
163 |
"user_id": request.args.get("user_id", ""),
|
164 |
+
"message": [{"role": "assistant", "content": canvas.get_prologue()}],
|
165 |
"source": "agent"
|
166 |
}
|
167 |
API4ConversationService.save(**conv)
|