From e52c3b984701129078d73c3b0eb1ae7553c7f0b4 Mon Sep 17 00:00:00 2001 From: sumansaurabh Date: Wed, 13 Nov 2024 03:16:54 +0000 Subject: [PATCH] feat(dualEncoder): increase top_k parameter for improved search results and enhance result processing output --- dualEncoder.py | 4 ++-- main.py | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dualEncoder.py b/dualEncoder.py index a77269a..44bf9de 100644 --- a/dualEncoder.py +++ b/dualEncoder.py @@ -192,7 +192,7 @@ def search( query: str, search_code: bool = True, search_docs: bool = True, - top_k: int = 2, + top_k: int = 5, min_similarity: float = 0.3 ) -> List[CodeAnalysisResult]: """ @@ -213,7 +213,7 @@ def search( code_query = code_query / (np.linalg.norm(code_query) + 1e-8) doc_query = doc_query / (np.linalg.norm(doc_query) + 1e-8) - results = [] + results: List[CodeAnalysisResult] = [] for func in self.functions: code_sim = 0.0 diff --git a/main.py b/main.py index 1b0fcf8..e122e3a 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ repo = "/Users/sumansaurabh/Documents/singularityx/github/MoneyPrinterTurbo/app/" repo = "/Users/sumansaurabh/Documents/singularityx/github/snorkell-backend/backend/" repo = "/home/azureuser/localfiles/pokerogue" +repo = "/home/azureuser/localfiles/snorkell-backend" encoder.index_repository( repo_path=repo, @@ -19,7 +20,7 @@ # Search with different focuses # 1. Search everything -message = "Increment the turn in the battle scene" +message = "add try catch block to the site uploader so that it can retry the upload if it fails" results = encoder.search( message, search_code=True, @@ -40,6 +41,8 @@ search_docs=True ) +print("####### OVerall Reusltes ##########") + # Process results for result in results: print(f"Function: {result.function.name}") @@ -49,7 +52,30 @@ print(f"Doc Similarity: {result.doc_similarity:.2f}") print(f"Combined: {result.combined_similarity:.2f}") print("\n\n") + +print("####### DOC Reusltes ##########") + +for result in doc_results: + print(f"Function: {result.function.name}") + print(f"File Path: {result.function.file_path}") + print(f"Docstring: {result.function.documentation}") + print(f"Code Similarity: {result.code_similarity:.2f}") + print(f"Doc Similarity: {result.doc_similarity:.2f}") + print(f"Combined: {result.combined_similarity:.2f}") + print("\n\n") + + +print("####### Code results##########") + +for result in code_results: + print(f"Function: {result.function.name}") + print(f"File Path: {result.function.file_path}") + print(f"Docstring: {result.function.documentation}") + print(f"Code Similarity: {result.code_similarity:.2f}") + print(f"Doc Similarity: {result.doc_similarity:.2f}") + print(f"Combined: {result.combined_similarity:.2f}") + print("\n\n") # # code results