debug backend API for TAB 'search' (#2389)

### What problem does this PR solve?
#2247

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Kevin Hu
2024-09-12 17:51:20 +08:00
committed by GitHub
parent 68d0210e92
commit 4730145696
6 changed files with 30 additions and 20 deletions

View File

@ -261,7 +261,7 @@ def retrieval_test():
kb_id = req["kb_id"]
if isinstance(kb_id, str): kb_id = [kb_id]
doc_ids = req.get("doc_ids", [])
similarity_threshold = float(req.get("similarity_threshold", 0.2))
similarity_threshold = float(req.get("similarity_threshold", 0.0))
vector_similarity_weight = float(req.get("vector_similarity_weight", 0.3))
top = int(req.get("top_k", 1024))

View File

@ -15,8 +15,8 @@
#
import json
import re
import traceback
from copy import deepcopy
from api.db.services.user_service import UserTenantService
from flask import request, Response
from flask_login import login_required, current_user
@ -333,6 +333,8 @@ def mindmap():
0.3, 0.3, aggs=False)
mindmap = MindMapExtractor(chat_mdl)
mind_map = mindmap([c["content_with_weight"] for c in ranks["chunks"]]).output
if "error" in mind_map:
return server_error_response(Exception(mind_map["error"]))
return get_json_result(data=mind_map)

View File

@ -218,7 +218,7 @@ def chat(dialog, messages, stream=True, **kwargs):
for ans in chat_mdl.chat_streamly(prompt, msg[1:], gen_conf):
answer = ans
delta_ans = ans[len(last_ans):]
if num_tokens_from_string(delta_ans) < 12:
if num_tokens_from_string(delta_ans) < 16:
continue
last_ans = answer
yield {"answer": answer, "reference": {}, "audio_binary": tts(tts_mdl, delta_ans)}
@ -404,7 +404,6 @@ def rewrite(tenant_id, llm_id, question):
def tts(tts_mdl, text):
return
if not tts_mdl or not text: return
bin = b""
for chunk in tts_mdl.tts(text):