openvector_dev 0.1.28__tar.gz → 0.1.32__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.3
2
2
  Name: openvector_dev
3
- Version: 0.1.28
3
+ Version: 0.1.32
4
4
  Summary:
5
5
  Author: p00ler
6
6
  Author-email: liveitspain@gmail.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "openvector_dev"
3
- version = "0.1.28"
3
+ version = "0.1.32"
4
4
  description = ""
5
5
  authors = [
6
6
  {name = "p00ler",email = "liveitspain@gmail.com"}
@@ -145,7 +145,7 @@ class Memory:
145
145
  log.info(curr_no % (block_size * self.merge_n))
146
146
  if curr_no % (block_size * self.merge_n) == 0:
147
147
  try:
148
- log.debug(f'Summary requested {bot}:{user_id}')
148
+ log.info(f'Summary requested {bot}:{user_id}')
149
149
  merged_text, used_ids = await self.long.merge_old_chunks(
150
150
  user_id=user_id, bot=bot, chunk_type="type0", n=self.merge_n
151
151
  )
@@ -299,6 +299,8 @@ class Memory:
299
299
 
300
300
  await self.long.delete_all(user_id, bot)
301
301
 
302
+ await self.r.delete(f"msg_no:{bot}:{user_id}")
303
+
302
304
  self._msg_no.pop((user_id, bot), None)
303
305
  self._gift_fail.pop((user_id, bot), None)
304
306
 
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ from datetime import datetime
2
3
  from typing import Any
3
4
  from uuid import UUID
4
5
 
@@ -140,27 +141,33 @@ class QdrantAdapter:
140
141
  chunk_type: str,
141
142
  n: int = 5,
142
143
  ) -> list[ChunkPayload]:
144
+ """Вернуть n самых старых чанков данного типа для (user_id, bot)."""
145
+
143
146
  flt = Filter(
144
147
  must=[
145
- FieldCondition(key="user_id", match=MatchValue(value=user_id)),
148
+ FieldCondition(key="user_id", match=MatchValue(value=int(user_id))),
146
149
  FieldCondition(key="bot", match=MatchValue(value=bot)),
147
150
  FieldCondition(key="chunk_type", match=MatchValue(value=chunk_type)),
148
151
  ]
149
152
  )
150
153
 
151
- # собираем все подходящие точки одной командой
154
+ # вытягиваем все подходящие точки
152
155
  points, _ = await self.client.scroll(
153
156
  collection_name=self.collection,
154
157
  scroll_filter=flt,
155
158
  with_payload=True,
156
159
  with_vectors=False,
157
- limit=10_00,
158
- )
159
-
160
- # сортируем по времени создания
161
- sorted_points = sorted(
162
- (ChunkPayload(**p.payload) for p in points),
163
- key=lambda p: p.created_at,
160
+ limit=2048,
164
161
  )
165
162
 
166
- return sorted_points[:n]
163
+ def _ts(p):
164
+ ts = p.payload.get("created_at")
165
+ if isinstance(ts, (int, float)):
166
+ return ts
167
+ try:
168
+ return datetime.fromisoformat(ts).timestamp()
169
+ except Exception:
170
+ return 0
171
+
172
+ oldest = sorted(points, key=_ts)[:n]
173
+ return [ChunkPayload(**p.payload) for p in oldest]