Fix: no result if metadata returns none.
This commit is contained in:
parent
0d5589bfda
commit
54f0f45889
5 changed files with 8 additions and 6 deletions
|
|
@ -167,7 +167,7 @@ class Retrieval(ToolBase, ABC):
|
|||
flt["value"] = "".join(out_parts)
|
||||
doc_ids.extend(meta_filter(metas, filters, self._param.meta_data_filter.get("logic", "and")))
|
||||
if not doc_ids:
|
||||
doc_ids = None
|
||||
doc_ids = ["-999"]
|
||||
|
||||
if self._param.cross_languages:
|
||||
query = cross_languages(kbs[0].tenant_id, None, query, self._param.cross_languages)
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ async def retrieval_test():
|
|||
elif meta_data_filter.get("method") == "manual":
|
||||
doc_ids.extend(meta_filter(metas, meta_data_filter["manual"], meta_data_filter.get("logic", "and")))
|
||||
if not doc_ids:
|
||||
doc_ids = None
|
||||
doc_ids = ["-999"]
|
||||
|
||||
try:
|
||||
tenants = UserTenantService.query(user_id=current_user.id)
|
||||
|
|
|
|||
|
|
@ -1445,6 +1445,8 @@ async def retrieval_test(tenant_id):
|
|||
metadata_condition = req.get("metadata_condition", {}) or {}
|
||||
metas = DocumentService.get_meta_by_kbs(kb_ids)
|
||||
doc_ids = meta_filter(metas, convert_conditions(metadata_condition), metadata_condition.get("logic", "and"))
|
||||
if not doc_ids:
|
||||
doc_ids = ["-999"]
|
||||
similarity_threshold = float(req.get("similarity_threshold", 0.2))
|
||||
vector_similarity_weight = float(req.get("vector_similarity_weight", 0.3))
|
||||
top = int(req.get("top_k", 1024))
|
||||
|
|
|
|||
|
|
@ -982,7 +982,7 @@ async def retrieval_test_embedded():
|
|||
elif meta_data_filter.get("method") == "manual":
|
||||
doc_ids.extend(meta_filter(metas, meta_data_filter["manual"], meta_data_filter.get("logic", "and")))
|
||||
if not doc_ids:
|
||||
doc_ids = None
|
||||
doc_ids = ["-999"]
|
||||
|
||||
try:
|
||||
tenants = UserTenantService.query(user_id=tenant_id)
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ def chat(dialog, messages, stream=True, **kwargs):
|
|||
elif dialog.meta_data_filter.get("method") == "manual":
|
||||
attachments.extend(meta_filter(metas, dialog.meta_data_filter["manual"], dialog.meta_data_filter.get("logic", "and")))
|
||||
if not attachments:
|
||||
attachments = None
|
||||
attachments = ["-999"]
|
||||
|
||||
if prompt_config.get("keyword", False):
|
||||
questions[-1] += keyword_extraction(chat_mdl, questions[-1])
|
||||
|
|
@ -788,7 +788,7 @@ def ask(question, kb_ids, tenant_id, chat_llm_name=None, search_config={}):
|
|||
elif meta_data_filter.get("method") == "manual":
|
||||
doc_ids.extend(meta_filter(metas, meta_data_filter["manual"], meta_data_filter.get("logic", "and")))
|
||||
if not doc_ids:
|
||||
doc_ids = None
|
||||
doc_ids = ["-999"]
|
||||
|
||||
kbinfos = retriever.retrieval(
|
||||
question=question,
|
||||
|
|
@ -863,7 +863,7 @@ def gen_mindmap(question, kb_ids, tenant_id, search_config={}):
|
|||
elif meta_data_filter.get("method") == "manual":
|
||||
doc_ids.extend(meta_filter(metas, meta_data_filter["manual"], meta_data_filter.get("logic", "and")))
|
||||
if not doc_ids:
|
||||
doc_ids = None
|
||||
doc_ids = ["-999"]
|
||||
|
||||
ranks = settings.retriever.retrieval(
|
||||
question=question,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue