Fix the agent reference bug and the session prologue (#3823)

### What problem does this PR solve?

Fix the agent reference bug and the session prologue
#3285 #3819
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
This commit is contained in:
liuhua 2024-12-03 14:49:26 +08:00 committed by GitHub
parent ccdeeda9cc
commit 95da6de9e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,7 +45,7 @@ def create(tenant_id,chat_id):
"id": get_uuid(), "id": get_uuid(),
"dialog_id": req["dialog_id"], "dialog_id": req["dialog_id"],
"name": req.get("name", "New session"), "name": req.get("name", "New session"),
"message": [{"role": "assistant", "content": "Hi! I am your assistantcan I help you?"}] "message": [{"role": "assistant", "content": dia[0].prompt_config.get("prologue")}]
} }
if not conv.get("name"): if not conv.get("name"):
return get_error_data_result(message="`name` can not be empty.") return get_error_data_result(message="`name` can not be empty.")
@ -274,7 +274,6 @@ def agent_completion(tenant_id, agent_id):
def fillin_conv(ans): def fillin_conv(ans):
reference = ans["reference"] reference = ans["reference"]
print(reference,flush=True)
temp_reference = deepcopy(ans["reference"]) temp_reference = deepcopy(ans["reference"])
nonlocal conv, message_id nonlocal conv, message_id
if not conv.reference: if not conv.reference:
@ -288,7 +287,7 @@ def agent_completion(tenant_id, agent_id):
for chunk in chunks: for chunk in chunks:
new_chunk = { new_chunk = {
"id": chunk["chunk_id"], "id": chunk["chunk_id"],
"content": chunk["content_with_weight"], "content": chunk["content"],
"document_id": chunk["doc_id"], "document_id": chunk["doc_id"],
"document_name": chunk["docnm_kwd"], "document_name": chunk["docnm_kwd"],
"dataset_id": chunk["kb_id"], "dataset_id": chunk["kb_id"],