openvector_dev 0.1.6__py3-none-any.whl → 0.1.7__py3-none-any.whl
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.
- lein_vector/api/facade.py +12 -22
- lein_vector/sentence_transformer.py +2 -3
- {openvector_dev-0.1.6.dist-info → openvector_dev-0.1.7.dist-info}/METADATA +1 -1
- {openvector_dev-0.1.6.dist-info → openvector_dev-0.1.7.dist-info}/RECORD +5 -5
- {openvector_dev-0.1.6.dist-info → openvector_dev-0.1.7.dist-info}/WHEEL +0 -0
lein_vector/api/facade.py
CHANGED
@@ -24,6 +24,8 @@ class Memory:
|
|
24
24
|
self._msg_no: dict[int, int] = {}
|
25
25
|
self.merge_n = merge_n
|
26
26
|
|
27
|
+
self.score_threshold = 0.72
|
28
|
+
|
27
29
|
@classmethod
|
28
30
|
async def from_qdrant(
|
29
31
|
cls,
|
@@ -207,33 +209,21 @@ class Memory:
|
|
207
209
|
data = await self.short.window(user_id, bot, n_memories)
|
208
210
|
return self._to_openai(data)
|
209
211
|
|
210
|
-
async def
|
211
|
-
self, user_id: int, embedding: list[float], topk: int = 3
|
212
|
-
) -> list:
|
213
|
-
"""
|
214
|
-
:param user_id: Идентификатор пользователя.
|
215
|
-
:param embedding: Вектор эмбеддинга для поиска.
|
216
|
-
:param topk: Количество возвращаемых чанков.
|
217
|
-
:returns: Список чанков.
|
218
|
-
"""
|
219
|
-
return await self.long.retrieve_by_embedding(user_id, embedding, topk)
|
220
|
-
|
221
|
-
async def _add_to_short(self, role: str, text: str) -> None:
|
222
|
-
"""
|
223
|
-
:param role: Роль сообщения.
|
224
|
-
:param text: Текст сообщения.
|
212
|
+
async def add_short_msg(self, user_id: int, bot: str, text: str, *, role: str = "user"):
|
225
213
|
"""
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
:param
|
231
|
-
:
|
214
|
+
Добавляет в "короткую память" новое сообщение
|
215
|
+
:param user_id: Идентификатор пользователя
|
216
|
+
:param bot: Кодовое имя бота
|
217
|
+
:param text: Сообщение для записи
|
218
|
+
:param role: Роль в диалоге
|
219
|
+
:type role: str = "user"
|
220
|
+
:return:
|
232
221
|
"""
|
233
|
-
await self.
|
222
|
+
await self.short.add(bot=bot, user_id=user_id, role=role, text=text)
|
234
223
|
|
235
224
|
async def delete_memory(self, user_id: int) -> None:
|
236
225
|
"""
|
226
|
+
Удаляет
|
237
227
|
:param user_id: Идентификатор пользователя.
|
238
228
|
"""
|
239
229
|
await self.long.delete_all(user_id)
|
@@ -22,11 +22,10 @@ class EmbeddingProviderGemini(EmbeddingProviderABC):
|
|
22
22
|
async def get_embedding(self, text: str) -> list[float]:
|
23
23
|
# В Gemini SDK обычно нет async, значит — обёртка через run_in_executor:
|
24
24
|
import asyncio
|
25
|
-
|
25
|
+
if not isinstance(text, str):
|
26
|
+
return
|
26
27
|
loop = asyncio.get_running_loop()
|
27
|
-
# SDK call внутри executor
|
28
28
|
embedding = await loop.run_in_executor(None, lambda: self._genai_embed(text))
|
29
|
-
# Ответ — dict с 'embedding' или 'values'
|
30
29
|
return embedding.embeddings[0].values
|
31
30
|
|
32
31
|
async def get_embeddings(self, texts: list[str]) -> list[list[float]]:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
lein_vector/__init__.py,sha256=ieXy65X4eVzUtSHNvlh00s4aMwKReafNni4s2q68z3Q,496
|
2
2
|
lein_vector/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
lein_vector/api/facade.py,sha256=
|
3
|
+
lein_vector/api/facade.py,sha256=f0Cwib5maw4Ae9QEmc5xDkx4Y2ozIzDQUqJ7jOdg2pg,10634
|
4
4
|
lein_vector/bases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
lein_vector/bases/embeding_provider_abc.py,sha256=WBpVC6ra-SYqhJeZs8R8U679wfGebXgwOOVPIii-IvY,265
|
6
6
|
lein_vector/bases/memory_manager_abc.py,sha256=pWuIw_wYlvUlt40jbiE92lWzdYaowZKg3XK0Mq0tQrw,1687
|
@@ -10,8 +10,8 @@ lein_vector/qdrant_adapter.py,sha256=uPhYAp0KmYQhY3DF29JMO1JTbM__xDWGlnZZPor3VKI
|
|
10
10
|
lein_vector/redis_short_term.py,sha256=uCcncjgXAlNAY46b3_Pjvrn_G0NEI16kRRR9hxayzak,3155
|
11
11
|
lein_vector/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
lein_vector/schemas/chunk.py,sha256=FSUwaFUSZk2ptoxupsdIfj5HYAMnHnu3eBfNpXCUMpM,1195
|
13
|
-
lein_vector/sentence_transformer.py,sha256=
|
13
|
+
lein_vector/sentence_transformer.py,sha256=gbWtkT01QFFA0IR_Ta-xsfBfb6owDzGnZDKY1g9fvBQ,1851
|
14
14
|
lein_vector/short_term.py,sha256=KFot9r26d9TZYLscVT42V0NwufIQUkx-hftOe2p7qLU,1933
|
15
|
-
openvector_dev-0.1.
|
16
|
-
openvector_dev-0.1.
|
17
|
-
openvector_dev-0.1.
|
15
|
+
openvector_dev-0.1.7.dist-info/METADATA,sha256=jNE4MlXel9eZ0iNEIg-JaFdIcAOCqBdxVUdVlNoKBqE,3167
|
16
|
+
openvector_dev-0.1.7.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
17
|
+
openvector_dev-0.1.7.dist-info/RECORD,,
|
File without changes
|