Kevin Hu
commited on
Commit
·
d9dc926
1
Parent(s):
f0b5f2b
hide referece when disable cite (#1535)
Browse files### What problem does this PR solve?
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
api/db/services/dialog_service.py
CHANGED
|
@@ -162,6 +162,7 @@ def chat(dialog, messages, stream=True, **kwargs):
|
|
| 162 |
|
| 163 |
def decorate_answer(answer):
|
| 164 |
nonlocal prompt_config, knowledges, kwargs, kbinfos
|
|
|
|
| 165 |
if knowledges and (prompt_config.get("quote", True) and kwargs.get("quote", True)):
|
| 166 |
answer, idx = retrievaler.insert_citations(answer,
|
| 167 |
[ck["content_ltks"]
|
|
@@ -177,10 +178,11 @@ def chat(dialog, messages, stream=True, **kwargs):
|
|
| 177 |
if not recall_docs: recall_docs = kbinfos["doc_aggs"]
|
| 178 |
kbinfos["doc_aggs"] = recall_docs
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
|
|
|
| 184 |
if answer.lower().find("invalid key") >= 0 or answer.lower().find("invalid api") >= 0:
|
| 185 |
answer += " Please set LLM API-Key in 'User Setting -> Model Providers -> API-Key'"
|
| 186 |
return {"answer": answer, "reference": refs}
|
|
|
|
| 162 |
|
| 163 |
def decorate_answer(answer):
|
| 164 |
nonlocal prompt_config, knowledges, kwargs, kbinfos
|
| 165 |
+
refs = []
|
| 166 |
if knowledges and (prompt_config.get("quote", True) and kwargs.get("quote", True)):
|
| 167 |
answer, idx = retrievaler.insert_citations(answer,
|
| 168 |
[ck["content_ltks"]
|
|
|
|
| 178 |
if not recall_docs: recall_docs = kbinfos["doc_aggs"]
|
| 179 |
kbinfos["doc_aggs"] = recall_docs
|
| 180 |
|
| 181 |
+
refs = deepcopy(kbinfos)
|
| 182 |
+
for c in refs["chunks"]:
|
| 183 |
+
if c.get("vector"):
|
| 184 |
+
del c["vector"]
|
| 185 |
+
|
| 186 |
if answer.lower().find("invalid key") >= 0 or answer.lower().find("invalid api") >= 0:
|
| 187 |
answer += " Please set LLM API-Key in 'User Setting -> Model Providers -> API-Key'"
|
| 188 |
return {"answer": answer, "reference": refs}
|