Skip to content

Commit

Permalink
Fix changed to openai embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrverdasca committed Nov 6, 2024
1 parent adf0aee commit 534644b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions labs/embeddings/vectorizers/chunk_vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from config import configuration_variables as settings
from labs.embeddings.base import Embedder
from labs.embeddings.ollama import OllamaEmbedder
from labs.embeddings.openai import OpenAIEmbedder
from labs.embeddings.vectorizers.base import Vectorizer

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -75,7 +75,7 @@ def vectorize_to_database(self, include_file_extensions, repo_destination):

logger.debug("Embedding all repo documents.")

embedder = Embedder(OllamaEmbedder, model="nomic-embed-text:latest")
embedder = Embedder(OpenAIEmbedder)
embeddings = embedder.embed(prompt=texts)

logger.debug("Storing all embeddings.")
Expand Down
4 changes: 2 additions & 2 deletions labs/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from config import configuration_variables as settings
from labs.decorators import time_and_log_function
from labs.embeddings.base import Embedder
from labs.embeddings.ollama import OllamaEmbedder
from labs.embeddings.openai import OpenAIEmbedder
from labs.embeddings.vectorizers.chunk_vectorizer import ChunkVectorizer
from labs.litellm_service.local import RequestLocalLLM
from labs.litellm_service.request import RequestLiteLLM
Expand Down Expand Up @@ -138,7 +138,7 @@ def call_llm_with_context(repo_destination, issue_summary):

ChunkVectorizer().vectorize_to_database(None, repo_destination)
# find_similar_embeddings narrows down codebase to files that matter for the issue at hand.
context = Embedder(OllamaEmbedder, model="nomic-embed-text:latest").retrieve_embeddings(issue_summary)
context = Embedder(OpenAIEmbedder).retrieve_embeddings(issue_summary)

prompt = get_prompt(issue_summary)
prepared_context = prepare_context(context, prompt)
Expand Down
4 changes: 2 additions & 2 deletions labs/tasks/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from config import configuration_variables as settings
from labs.celery import app
from labs.embeddings.base import Embedder
from labs.embeddings.ollama import OllamaEmbedder
from labs.embeddings.openai import OpenAIEmbedder
from labs.embeddings.vectorizers.chunk_vectorizer import ChunkVectorizer
from labs.llm import get_llm_response, get_prompt, prepare_context

Expand All @@ -27,7 +27,7 @@ def vectorize_repo_to_database_task(prefix="", repo_destination=""):

@app.task
def find_similar_embeddings_task(prefix="", issue_body=""):
rows = Embedder(OllamaEmbedder, model="nomic-embed-text:latest").retrieve_embeddings(
rows = Embedder(OpenAIEmbedder).retrieve_embeddings(
redis_client.get(f"{prefix}_issue_body") if prefix else issue_body
)
similar_embeddings = [(row[0], row[1], row[2]) for row in rows]
Expand Down

0 comments on commit 534644b

Please sign in to comment.