Switch to OpenAI embeddings for ChromaDB
Replace Ollama embedding function with OpenAI's text-embedding-3-small model for improved embedding quality and consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10
chunker.py
10
chunker.py
@@ -4,8 +4,8 @@ import re
|
|||||||
from typing import Union
|
from typing import Union
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
from chromadb.utils.embedding_functions.ollama_embedding_function import (
|
from chromadb.utils.embedding_functions.openai_embedding_function import (
|
||||||
OllamaEmbeddingFunction,
|
OpenAIEmbeddingFunction,
|
||||||
)
|
)
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ class Chunk:
|
|||||||
|
|
||||||
|
|
||||||
class Chunker:
|
class Chunker:
|
||||||
embedding_fx = OllamaEmbeddingFunction(
|
embedding_fx = OpenAIEmbeddingFunction(
|
||||||
url=os.getenv("OLLAMA_URL", "http://host.docker.internal:11434"),
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
model_name="mxbai-embed-large",
|
model_name="text-embedding-3-small",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, collection) -> None:
|
def __init__(self, collection) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user