Skip to content

Commit

Permalink
Implemented test_store:test_upload
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninoLorenzo committed Aug 25, 2024
1 parent c7647fc commit a8e052e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/agent/knowledge/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ollama
import qdrant_client.http.exceptions
from qdrant_client import QdrantClient, models
from qdrant_client.http.exceptions import UnexpectedResponse

from src.agent.llm.llm import ProviderError
from src.agent.knowledge.collections import Collection, Document, Topic
Expand Down Expand Up @@ -87,13 +88,16 @@ def create_collection(self, collection: Collection):
if collection.title in self.collections:
return None

done = self._connection.create_collection(
collection_name=collection.title,
vectors_config=models.VectorParams(
size=self._embedding_size,
distance=models.Distance.COSINE
try:
done = self._connection.create_collection(
collection_name=collection.title,
vectors_config=models.VectorParams(
size=self._embedding_size,
distance=models.Distance.COSINE
)
)
)
except UnexpectedResponse as err:
raise RuntimeError(f"Can't upload collection: {err}")

if done:
self._collections[collection.title] = collection
Expand Down Expand Up @@ -135,6 +139,8 @@ def create_collection(self, collection: Collection):
def upload(self, document: Document, collection_name: str):
"""Performs chunking and embedding of a document
and uploads it to the specified collection"""
if not isinstance(collection_name, str):
raise TypeError(f'Expected str for collection_name, found {type(collection_name)}')
if collection_name not in self._collections:
raise ValueError('Collection does not exist')

Expand Down

0 comments on commit a8e052e

Please sign in to comment.