base90-rag 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {base90_rag-0.2.2 → base90_rag-0.2.4}/PKG-INFO +1 -1
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag/core.py +31 -22
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag.egg-info/PKG-INFO +1 -1
- {base90_rag-0.2.2 → base90_rag-0.2.4}/pyproject.toml +1 -1
- {base90_rag-0.2.2 → base90_rag-0.2.4}/LICENSE +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/README.md +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag/__init__.py +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag/default_dict.json +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag.egg-info/SOURCES.txt +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag.egg-info/dependency_links.txt +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/base90_rag.egg-info/top_level.txt +0 -0
- {base90_rag-0.2.2 → base90_rag-0.2.4}/setup.cfg +0 -0
|
@@ -204,47 +204,56 @@ class Base90Memory:
|
|
|
204
204
|
valid_sets = []
|
|
205
205
|
for code in query_codes:
|
|
206
206
|
if code in self.mem_inverted:
|
|
207
|
-
|
|
208
|
-
if len(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
valid_sets.append(
|
|
207
|
+
inv_set = self.mem_inverted[code]
|
|
208
|
+
if len(inv_set) > 5000:
|
|
209
|
+
from itertools import islice
|
|
210
|
+
inv_set = set(islice(inv_set, 5000))
|
|
211
|
+
valid_sets.append(inv_set)
|
|
212
212
|
|
|
213
213
|
if not valid_sets: return []
|
|
214
214
|
|
|
215
215
|
valid_sets.sort(key=len)
|
|
216
|
-
|
|
217
216
|
candidate_pids = valid_sets[0].copy()
|
|
218
217
|
for i in range(1, len(valid_sets)):
|
|
219
218
|
candidate_pids = candidate_pids.intersection(valid_sets[i])
|
|
220
219
|
if not candidate_pids:
|
|
221
220
|
break
|
|
222
221
|
|
|
223
|
-
if len(candidate_pids) > 2000:
|
|
224
|
-
from itertools import islice
|
|
225
|
-
candidate_pids = set(islice(candidate_pids, 2000))
|
|
226
|
-
|
|
227
222
|
final_results = []
|
|
228
223
|
|
|
224
|
+
clean_query = query.replace(" ", "").lower()
|
|
225
|
+
|
|
226
|
+
def _is_match(raw_text):
|
|
227
|
+
if query in raw_text:
|
|
228
|
+
return True
|
|
229
|
+
if clean_query in raw_text.replace(" ", "").lower():
|
|
230
|
+
return True
|
|
231
|
+
return False
|
|
232
|
+
|
|
229
233
|
if candidate_pids:
|
|
234
|
+
check_count = 0
|
|
230
235
|
for pid in candidate_pids:
|
|
231
236
|
v = self.mem_vaults.get(pid)
|
|
232
|
-
if v and
|
|
237
|
+
if v and _is_match(v["text"]):
|
|
233
238
|
final_results.append(v["text"])
|
|
234
239
|
if len(final_results) >= limit:
|
|
235
240
|
return final_results
|
|
241
|
+
check_count += 1
|
|
242
|
+
if check_count > 2000: # 保险丝
|
|
243
|
+
break
|
|
236
244
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
if len(final_results) < limit:
|
|
246
|
+
check_count = 0
|
|
247
|
+
for pid in valid_sets[0]:
|
|
248
|
+
v = self.mem_vaults.get(pid)
|
|
249
|
+
if v and v["text"] not in final_results:
|
|
250
|
+
if _is_match(v["text"]):
|
|
251
|
+
final_results.append(v["text"])
|
|
252
|
+
if len(final_results) >= limit:
|
|
253
|
+
break
|
|
254
|
+
check_count += 1
|
|
255
|
+
if check_count > 300:
|
|
256
|
+
break
|
|
248
257
|
|
|
249
258
|
return final_results
|
|
250
259
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|