Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Feat: Allow update conversation parameters and persist to database in completion (#8039)

天海蒼灆9938a4cbb672
diff --git a/api/db/services/canvas_service.py b/api/db/services/canvas_service.py
index bca6a6be91..5d98878fc2 100644
--- a/api/db/services/canvas_service.py
+++ b/api/db/services/canvas_service.py
@@ -173,6 +173,19 @@ def completion(tenant_id, agent_id, question, session_id=None, stream=True, **kw
conv.reference = []
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": ""}
if stream:
try: