base90-rag 0.2.2__tar.gz → 0.2.3__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.3
4
4
  Summary: 超极速、零算力、零幻觉的纯文本 RAG 检索结构 (Base90 极简硬路由)
5
5
  Author-email: Flowerdance <admin@example.com>
6
6
  License: MIT
@@ -204,47 +204,58 @@ 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))
222
+ import re
223
+ clean_query = re.sub(r'\s+', '', query).lower()
226
224
 
227
225
  final_results = []
228
226
 
227
+ def _is_match(raw_text):
228
+ if query in raw_text:
229
+ return True
230
+
231
+ if clean_query in raw_text.replace(" ", "").lower():
232
+ return True
233
+ return False
234
+
229
235
  if candidate_pids:
236
+ check_count = 0
230
237
  for pid in candidate_pids:
231
238
  v = self.mem_vaults.get(pid)
232
- if v and query in v["text"]:
239
+ if v and _is_match(v["text"]):
233
240
  final_results.append(v["text"])
234
241
  if len(final_results) >= limit:
235
242
  return final_results
243
+ check_count += 1
244
+ if check_count > 2000:
245
+ break
236
246
 
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
247
+ if len(final_results) < limit:
248
+ check_count = 0
249
+ for pid in valid_sets[0]:
250
+ v = self.mem_vaults.get(pid)
251
+ if v and v["text"] not in final_results:
252
+ if _is_match(v["text"]):
253
+ final_results.append(v["text"])
254
+ if len(final_results) >= limit:
255
+ break
256
+ check_count += 1
257
+ if check_count > 300:
258
+ break
248
259
 
249
260
  return final_results
250
261
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: base90-rag
3
- Version: 0.2.2
3
+ Version: 0.2.3
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.3"
8
8
  authors = [
9
9
  { name="Flowerdance", email="admin@example.com" }
10
10
  ]
File without changes
File without changes
File without changes