diff --git a/codeqai/app.py b/codeqai/app.py index 9a620de..faf0362 100644 --- a/codeqai/app.py +++ b/codeqai/app.py @@ -8,8 +8,7 @@ from yaspin import yaspin from codeqai import codeparser, repo, utils -from codeqai.config import (create_cache_dir, create_config, get_cache_path, - load_config) +from codeqai.config import create_cache_dir, create_config, get_cache_path, load_config from codeqai.constants import EmbeddingsModel, LllmHost from codeqai.embeddings import Embeddings from codeqai.llm import LLM @@ -42,7 +41,7 @@ def run(): create_cache_dir() embeddings_model = Embeddings( - local=True, + local=config["local"], model=EmbeddingsModel[config["embeddings"].upper().replace("-", "_")], deployment=config["embeddings-deployment"] if "embeddings-deployment" in config @@ -94,11 +93,17 @@ def run(): language = utils.get_programming_language( utils.get_file_extension(doc.metadata["filename"]) ) + syntax = Syntax( - doc.page_content, language.value, theme="monokai", line_numbers=True + doc.page_content, + language.value, + theme="monokai", + line_numbers=True, ) console = Console() + print(doc.metadata["filename"] + " -> " + doc.metadata["method_name"]) console.print(syntax) + print() choice = input("[?] (C)ontinue search or (E)xit [C]:").strip().lower() diff --git a/codeqai/codeparser.py b/codeqai/codeparser.py index 564255d..54e8eae 100644 --- a/codeqai/codeparser.py +++ b/codeqai/codeparser.py @@ -1,5 +1,4 @@ import os -import re from langchain.schema import Document from langchain.text_splitter import RecursiveCharacterTextSplitter @@ -19,9 +18,7 @@ def parse_code_files(code_files: list[str]) -> list[Document]: file_extension = utils.get_file_extension(code_file) programming_language = utils.get_programming_language(file_extension) if programming_language == Language.UNKNOWN: - print( - f"Skipping file {code_file} with unsupported programming language" - ) + continue langchain_language = utils.get_langchain_language(programming_language) diff --git a/codeqai/config.py b/codeqai/config.py index b359106..6d929f3 100644 --- a/codeqai/config.py +++ b/codeqai/config.py @@ -100,7 +100,8 @@ def create_config(): "llm-host", message="Which remote LLM do you want to use?", choices=[ - "OpenAI" "Azure-OpenAI", + "OpenAI", + "Azure-OpenAI", ], default="OpenAI", ), diff --git a/codeqai/embeddings.py b/codeqai/embeddings.py index 604c91b..2d99cbe 100644 --- a/codeqai/embeddings.py +++ b/codeqai/embeddings.py @@ -17,12 +17,10 @@ def __init__( if not local: if model == EmbeddingsModel.OPENAI_TEXT_EMBEDDING_ADA_002: self.embeddings = OpenAIEmbeddings( - client=None, model="text_embedding_ada_002" + client=None, model="text-embedding-ada-002" ) elif model == EmbeddingsModel.AZURE_OPENAI and deployment: - self.embeddings = OpenAIEmbeddings( - client=None, model="text_embedding_ada_002", deployment=deployment - ) + self.embeddings = OpenAIEmbeddings(client=None, deployment=deployment) else: try: import sentence_transformers # noqa: F401