ソースを参照

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)
tags/v0.19.1
天海蒼灆 5ヶ月前
コミット
9938a4cbb6
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更13行の追加0行の削除
  1. 13
    0
      api/db/services/canvas_service.py

+ 13
- 0
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:

読み込み中…
キャンセル
保存