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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: base90-rag
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: 超极速、零算力、零幻觉的纯文本 RAG 检索结构 (Base90 极简硬路由)
5
5
  Author-email: Flowerdance <admin@example.com>
6
6
  License: MIT
@@ -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
- word = self.code_to_word.get(code, "")
208
- if len(word) == 1 and word in "的了是我你他她它": continue
209
- if len(word) == 1 and word.isascii() and word.isalpha(): continue
210
-
211
- valid_sets.append(self.mem_inverted[code])
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 query in v["text"]:
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
- count = 0
238
- for pid in valid_sets[0]:
239
- v = self.mem_vaults.get(pid)
240
- if v and v["text"] not in final_results: # 去重
241
- if query in v["text"]: # 硬校验
242
- final_results.append(v["text"])
243
- if len(final_results) >= limit:
244
- break
245
- count += 1
246
- if count > 2000:
247
- break
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: base90-rag
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: 超极速、零算力、零幻觉的纯文本 RAG 检索结构 (Base90 极简硬路由)
5
5
  Author-email: Flowerdance <admin@example.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "base90-rag"
7
- version = "0.2.2"
7
+ version = "0.2.4"
8
8
  authors = [
9
9
  { name="Flowerdance", email="admin@example.com" }
10
10
  ]
File without changes
File without changes
File without changes