浏览代码

Fix chunk enable/disable issue (#3579)

### What problem does this PR solve?

#3576

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.14.0
Kevin Hu 11 个月前
父节点
当前提交
9f3141804f
没有帐户链接到提交者的电子邮件
共有 4 个文件被更改,包括 16 次插入7 次删除
  1. 6
    3
      api/apps/chunk_app.py
  2. 2
    2
      api/apps/user_app.py
  3. 1
    1
      rag/nlp/search.py
  4. 7
    1
      rag/utils/es_conn.py

+ 6
- 3
api/apps/chunk_app.py 查看文件

e, doc = DocumentService.get_by_id(req["doc_id"]) e, doc = DocumentService.get_by_id(req["doc_id"])
if not e: if not e:
return get_data_error_result(message="Document not found!") return get_data_error_result(message="Document not found!")
if not settings.docStoreConn.update({"id": req["chunk_ids"]}, {"available_int": int(req["available_int"])},
search.index_name(doc.tenant_id), doc.kb_id):
return get_data_error_result(message="Index updating failure")
for cid in req["chunk_ids"]:
if not settings.docStoreConn.update({"id": cid},
{"available_int": int(req["available_int"])},
search.index_name(DocumentService.get_tenant_id(req["doc_id"])),
doc.kb_id):
return get_data_error_result(message="Index updating failure")
return get_json_result(data=True) return get_json_result(data=True)
except Exception as e: except Exception as e:
return server_error_response(e) return server_error_response(e)

+ 2
- 2
api/apps/user_app.py 查看文件

"llm_name": llm.llm_name, "llm_name": llm.llm_name,
"model_type": llm.model_type, "model_type": llm.model_type,
"api_key": settings.API_KEY, "api_key": settings.API_KEY,
"api_base": settings.LLM_BASE_URL
#"max_tokens": llm.max_tokens if llm.max_tokens else 8192
"api_base": settings.LLM_BASE_URL,
"max_tokens": llm.max_tokens if llm.max_tokens else 8192
} }
) )



+ 1
- 1
rag/nlp/search.py 查看文件

if key in req and req[key] is not None: if key in req and req[key] is not None:
condition[field] = req[key] condition[field] = req[key]
# TODO(yzc): `available_int` is nullable however infinity doesn't support nullable columns. # TODO(yzc): `available_int` is nullable however infinity doesn't support nullable columns.
for key in ["knowledge_graph_kwd"]:
for key in ["knowledge_graph_kwd", "available_int"]:
if key in req and req[key] is not None: if key in req and req[key] is not None:
condition[key] = req[key] condition[key] = req[key]
return condition return condition

+ 7
- 1
rag/utils/es_conn.py 查看文件

bqry = Q("bool", must=[]) bqry = Q("bool", must=[])
condition["kb_id"] = knowledgebaseIds condition["kb_id"] = knowledgebaseIds
for k, v in condition.items(): for k, v in condition.items():
if not isinstance(k, str) or not v:
if k == "available_int":
if v == 0:
bqry.filter.append(Q("range", available_int={"lt": 1}))
else:
bqry.filter.append(
Q("bool", must_not=Q("range", available_int={"lt": 1})))
continue continue
if not v: continue
if isinstance(v, list): if isinstance(v, list):
bqry.filter.append(Q("terms", **{k: v})) bqry.filter.append(Q("terms", **{k: v}))
elif isinstance(v, str) or isinstance(v, int): elif isinstance(v, str) or isinstance(v, int):

正在加载...
取消
保存