Skip to content

Commit d09a2a5

Browse files
committed
Refactor embedding function and add support for different repositories
1 parent ff6543b commit d09a2a5

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

createEmbeddings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from qdrant_client import QdrantClient
88
from qdrant_client.models import CollectionDescription, Distance, VectorParams, Record
99

10-
def embed_sample_functions():
10+
def embed_sample_functions(repo_path):
1111
# Initialize Qdrant Client
1212
client = QdrantClient(host='localhost', port=6333)
1313
# client = QdrantClient(":memory:")
@@ -17,7 +17,7 @@ def embed_sample_functions():
1717
openai.api_key = os.getenv("OPENAI_API_KEY")
1818

1919
# Load the JSON data from the file
20-
json_file_path = 'outputData/function_changes.json' # depends on how you run the file, should be changed to be global and not local path
20+
json_file_path = 'outputData/test_function_changes.json' if repo_path.endswith('testRepo') else 'outputData/function_changes.json'
2121
with open(json_file_path, 'r') as file:
2222
json_data = json.load(file)
2323

main.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
import createEmbeddings
55
from userInput import processUserInput
66

7-
# Run the main function from getFunctionData
8-
# pass this variable if you want to run another repo than testRepo:
9-
# repo_path='../inputData/elixirsolutions'
10-
getFunctionData.get_function_data()
7+
def main(repo_path='../inputData/testRepo'):
8+
# Run the main function from getFunctionData
9+
getFunctionData.get_function_data(repo_path)
1110

12-
# Run the main function from createEmbeddings
13-
createEmbeddings.embed_sample_functions()
11+
# Run the main function from createEmbeddings
12+
createEmbeddings.embed_sample_functions(repo_path)
1413

15-
# Run the main function from processUserInput
16-
processUserInput.process_user_input()
14+
# Run the main function from processUserInput
15+
processUserInput.process_user_input()
1716

18-
# Create a test suite
19-
suite = unittest.TestLoader().loadTestsFromModule(test_get_function_data)
17+
# Create a test suite
18+
suite = unittest.TestLoader().loadTestsFromModule(test_get_function_data)
2019

21-
# Run the tests with CustomTestRunner
22-
test_get_function_data.CustomTestRunner().run(suite)
20+
# Run the tests with CustomTestRunner
21+
test_get_function_data.CustomTestRunner().run(suite)
22+
23+
if __name__ == '__main__':
24+
# pass this variable if you want to run another repo than testRepo:
25+
# repo_path='../inputData/elixirsolutions'
26+
main()

0 commit comments

Comments
 (0)