LiKenun commited on
Commit
40a7d2c
·
1 Parent(s): 7aeec4b

Fix minor bugs with poorly qualified symbols

Browse files
src/ctp_slack_bot/db/repositories/mongo_db_vectorized_chunk_repository.py CHANGED
@@ -1,6 +1,6 @@
1
  from dependency_injector.resources import AsyncResource
2
  from loguru import logger
3
- from pymongo import ReturnDocument
4
  from typing import Any, Collection, Dict, Iterable, Mapping, Optional, Self, Sequence, Set
5
 
6
  from ctp_slack_bot.core import Settings
@@ -149,7 +149,7 @@ class MongoVectorizedChunkRepository(VectorRepositoryBase, VectorizedChunkReposi
149
  async def ensure_indices_exist(self: Self) -> None:
150
  await super().ensure_indices_exist()
151
  index_name = "parent_chunk_unique"
152
- existing_indices = await collection.index_information()
153
  if index_name not in existing_indices:
154
  await self.collection.create_index([("parent_id", ASCENDING), ("chunk_id", ASCENDING)], unique=True, name=index_name)
155
 
@@ -157,5 +157,5 @@ class MongoVectorizedChunkRepositoryResource(AsyncResource):
157
  async def init(self: Self, settings: Settings, mongo_db: MongoDB) -> MongoVectorizedChunkRepository:
158
  vectorized_chunk_collection = await mongo_db.get_collection("vectorized_chunks")
159
  vectorized_chunk_repository = MongoVectorizedChunkRepository(settings=settings, collection=vectorized_chunk_collection)
160
- await vectorized_chunk_repository.ensure_indices_exists()
161
  return vectorized_chunk_repository
 
1
  from dependency_injector.resources import AsyncResource
2
  from loguru import logger
3
+ from pymongo import ASCENDING, ReturnDocument
4
  from typing import Any, Collection, Dict, Iterable, Mapping, Optional, Self, Sequence, Set
5
 
6
  from ctp_slack_bot.core import Settings
 
149
  async def ensure_indices_exist(self: Self) -> None:
150
  await super().ensure_indices_exist()
151
  index_name = "parent_chunk_unique"
152
+ existing_indices = await self.collection.index_information()
153
  if index_name not in existing_indices:
154
  await self.collection.create_index([("parent_id", ASCENDING), ("chunk_id", ASCENDING)], unique=True, name=index_name)
155
 
 
157
  async def init(self: Self, settings: Settings, mongo_db: MongoDB) -> MongoVectorizedChunkRepository:
158
  vectorized_chunk_collection = await mongo_db.get_collection("vectorized_chunks")
159
  vectorized_chunk_repository = MongoVectorizedChunkRepository(settings=settings, collection=vectorized_chunk_collection)
160
+ await vectorized_chunk_repository.ensure_indices_exist()
161
  return vectorized_chunk_repository
src/ctp_slack_bot/db/repositories/vector_repository_base.py CHANGED
@@ -19,7 +19,7 @@ class VectorRepositoryBase(ABC, BaseModel):
19
 
20
  async def ensure_indices_exist(self: Self) -> None:
21
  """Ensure that indices exist."""
22
- self.ensure_search_index_exists()
23
 
24
  async def ensure_search_index_exists(self: Self) -> None:
25
  """
 
19
 
20
  async def ensure_indices_exist(self: Self) -> None:
21
  """Ensure that indices exist."""
22
+ await self.ensure_search_index_exists()
23
 
24
  async def ensure_search_index_exists(self: Self) -> None:
25
  """