Skip to content

Commit

Permalink
Fix chunk enable/disable issue (infiniflow#3579)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

infiniflow#3576

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
KevinHuSh authored Nov 22, 2024
1 parent 60a3e1a commit 9f31418
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions api/apps/chunk_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ def switch():
e, doc = DocumentService.get_by_id(req["doc_id"])
if not e:
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)
except Exception as e:
return server_error_response(e)
Expand Down
4 changes: 2 additions & 2 deletions api/apps/user_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ def user_register(user_id, user):
"llm_name": llm.llm_name,
"model_type": llm.model_type,
"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
}
)

Expand Down
2 changes: 1 addition & 1 deletion rag/nlp/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_filters(self, req):
if key in req and req[key] is not None:
condition[field] = req[key]
# 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:
condition[key] = req[key]
return condition
Expand Down
8 changes: 7 additions & 1 deletion rag/utils/es_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ def search(self, selectFields: list[str], highlightFields: list[str], condition:
bqry = Q("bool", must=[])
condition["kb_id"] = knowledgebaseIds
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
if not v: continue
if isinstance(v, list):
bqry.filter.append(Q("terms", **{k: v}))
elif isinstance(v, str) or isinstance(v, int):
Expand Down

0 comments on commit 9f31418

Please sign in to comment.