Adding getenv to main

This commit is contained in:
2025-07-26 19:46:55 -04:00
parent 994b3fdf1f
commit 943a22401b
2 changed files with 13 additions and 3 deletions

11
main.py
View File

@@ -1,4 +1,5 @@
import ollama
import os
from uuid import uuid4, UUID
from request import PaperlessNGXService
@@ -11,9 +12,13 @@ from chromadb.utils.embedding_functions.ollama_embedding_function import (
OllamaEmbeddingFunction,
)
from dotenv import load_dotenv
client = chromadb.EphemeralClient()
collection = client.create_collection(name="docs")
load_dotenv()
class Chunk:
def __init__(
@@ -34,7 +39,7 @@ class Chunk:
class Chunker:
def __init__(self) -> None:
self.embedding_fx = OllamaEmbeddingFunction(
url="http://localhost:11434",
url=os.getenv("OLLAMA_URL", ""),
model_name="mxbai-embed-large",
)
@@ -67,7 +72,7 @@ class Chunker:
embedding_fx = OllamaEmbeddingFunction(
url="http://localhost:11434",
url=os.getenv("OLLAMA_URL", ""),
model_name="mxbai-embed-large",
)
@@ -84,7 +89,7 @@ for text in texts:
chunker.chunk_document(document=text)
# Ask
input = "How many teeth has Simba had removed?"
input = "How many teeth has Simba had removed? Who is his current vet?"
embeddings = embedding_fx(input=[input])
results = collection.query(query_texts=[input], query_embeddings=embeddings)
print(results)