mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Feat: Allow update conversation parameters and persist to database in completion (#8039)
### What problem does this PR solve? This PR updates the completion function to allow parameter updates when a session_id exists. It also ensures changes are saved back to the database via API4ConversationService. ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -173,6 +173,19 @@ def completion(tenant_id, agent_id, question, session_id=None, stream=True, **kw
|
|||||||
conv.reference = []
|
conv.reference = []
|
||||||
conv.reference.append({"chunks": [], "doc_aggs": []})
|
conv.reference.append({"chunks": [], "doc_aggs": []})
|
||||||
|
|
||||||
|
kwargs_changed = False
|
||||||
|
if kwargs:
|
||||||
|
query = canvas.get_preset_param()
|
||||||
|
if query:
|
||||||
|
for ele in query:
|
||||||
|
if ele["key"] in kwargs:
|
||||||
|
if ele["value"] != kwargs[ele["key"]]:
|
||||||
|
ele["value"] = kwargs[ele["key"]]
|
||||||
|
kwargs_changed = True
|
||||||
|
if kwargs_changed:
|
||||||
|
conv.dsl = json.loads(str(canvas))
|
||||||
|
API4ConversationService.update_by_id(session_id, {"dsl": conv.dsl})
|
||||||
|
|
||||||
final_ans = {"reference": [], "content": ""}
|
final_ans = {"reference": [], "content": ""}
|
||||||
if stream:
|
if stream:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user