Kevin Hu
commited on
Commit
·
28a7a7b
1
Parent(s):
2964cd4
Fix chunk enable/disable issue (#3579)
Browse files### What problem does this PR solve?
#3576
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- api/apps/chunk_app.py +6 -3
- api/apps/user_app.py +2 -2
- rag/nlp/search.py +1 -1
- rag/utils/es_conn.py +7 -1
api/apps/chunk_app.py
CHANGED
@@ -170,9 +170,12 @@ def switch():
|
|
170 |
e, doc = DocumentService.get_by_id(req["doc_id"])
|
171 |
if not e:
|
172 |
return get_data_error_result(message="Document not found!")
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
|
|
|
|
176 |
return get_json_result(data=True)
|
177 |
except Exception as e:
|
178 |
return server_error_response(e)
|
|
|
170 |
e, doc = DocumentService.get_by_id(req["doc_id"])
|
171 |
if not e:
|
172 |
return get_data_error_result(message="Document not found!")
|
173 |
+
for cid in req["chunk_ids"]:
|
174 |
+
if not settings.docStoreConn.update({"id": cid},
|
175 |
+
{"available_int": int(req["available_int"])},
|
176 |
+
search.index_name(DocumentService.get_tenant_id(req["doc_id"])),
|
177 |
+
doc.kb_id):
|
178 |
+
return get_data_error_result(message="Index updating failure")
|
179 |
return get_json_result(data=True)
|
180 |
except Exception as e:
|
181 |
return server_error_response(e)
|
api/apps/user_app.py
CHANGED
@@ -517,8 +517,8 @@ def user_register(user_id, user):
|
|
517 |
"llm_name": llm.llm_name,
|
518 |
"model_type": llm.model_type,
|
519 |
"api_key": settings.API_KEY,
|
520 |
-
"api_base": settings.LLM_BASE_URL
|
521 |
-
|
522 |
}
|
523 |
)
|
524 |
|
|
|
517 |
"llm_name": llm.llm_name,
|
518 |
"model_type": llm.model_type,
|
519 |
"api_key": settings.API_KEY,
|
520 |
+
"api_base": settings.LLM_BASE_URL,
|
521 |
+
"max_tokens": llm.max_tokens if llm.max_tokens else 8192
|
522 |
}
|
523 |
)
|
524 |
|
rag/nlp/search.py
CHANGED
@@ -56,7 +56,7 @@ class Dealer:
|
|
56 |
if key in req and req[key] is not None:
|
57 |
condition[field] = req[key]
|
58 |
# TODO(yzc): `available_int` is nullable however infinity doesn't support nullable columns.
|
59 |
-
for key in ["knowledge_graph_kwd"]:
|
60 |
if key in req and req[key] is not None:
|
61 |
condition[key] = req[key]
|
62 |
return condition
|
|
|
56 |
if key in req and req[key] is not None:
|
57 |
condition[field] = req[key]
|
58 |
# TODO(yzc): `available_int` is nullable however infinity doesn't support nullable columns.
|
59 |
+
for key in ["knowledge_graph_kwd", "available_int"]:
|
60 |
if key in req and req[key] is not None:
|
61 |
condition[key] = req[key]
|
62 |
return condition
|
rag/utils/es_conn.py
CHANGED
@@ -121,8 +121,14 @@ class ESConnection(DocStoreConnection):
|
|
121 |
bqry = Q("bool", must=[])
|
122 |
condition["kb_id"] = knowledgebaseIds
|
123 |
for k, v in condition.items():
|
124 |
-
if
|
|
|
|
|
|
|
|
|
|
|
125 |
continue
|
|
|
126 |
if isinstance(v, list):
|
127 |
bqry.filter.append(Q("terms", **{k: v}))
|
128 |
elif isinstance(v, str) or isinstance(v, int):
|
|
|
121 |
bqry = Q("bool", must=[])
|
122 |
condition["kb_id"] = knowledgebaseIds
|
123 |
for k, v in condition.items():
|
124 |
+
if k == "available_int":
|
125 |
+
if v == 0:
|
126 |
+
bqry.filter.append(Q("range", available_int={"lt": 1}))
|
127 |
+
else:
|
128 |
+
bqry.filter.append(
|
129 |
+
Q("bool", must_not=Q("range", available_int={"lt": 1})))
|
130 |
continue
|
131 |
+
if not v: continue
|
132 |
if isinstance(v, list):
|
133 |
bqry.filter.append(Q("terms", **{k: v}))
|
134 |
elif isinstance(v, str) or isinstance(v, int):
|