Skip to content

Commit

Permalink
Added embedding model init parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninoLorenzo committed Aug 3, 2024
1 parent dc33343 commit 484d0f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/agent/knowledge/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Store:
def __init__(self,
url: str = 'http://localhost:6333',
embedding_url: str = 'http://localhost:11434',
embedding_model: str = 'nomic-embed-text',
in_memory: bool = False,
router: Router = None
):
Expand All @@ -40,7 +41,7 @@ def __init__(self,
self._collections: Dict[str: Collection] = coll

self._encoder = ollama.Client(host=embedding_url).embeddings
self._embedding_model: str = 'nomic-embed-text'
self._embedding_model: str = embedding_model
self._embedding_size: int = len(
self._encoder(
self._embedding_model,
Expand Down Expand Up @@ -111,14 +112,14 @@ def upload(self, document: Document, collection_name: str):
'title': document.name,
'topic': str(document.topic),
'text': ch,
'embedding': self._encoder(self._embedding_model, ch)
'embedding': self._encoder(self._embedding_model, ch)['embedding']
} for ch in doc_chunks]
current_len = self._collections[collection_name].size

points = [
models.PointStruct(
id=current_len + i,
vector=item['embedding']['embedding'],
vector=item['embedding'],
payload={'text': item['text'], 'title': item['title'], 'topic': item['topic']}
)
for i, item in enumerate(emb_chunks)
Expand Down

0 comments on commit 484d0f2

Please sign in to comment.