Skip to content

Commit

Permalink
Refactor embedding function and add support for different repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-t committed Jan 3, 2024
1 parent ff6543b commit d09a2a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions createEmbeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from qdrant_client import QdrantClient
from qdrant_client.models import CollectionDescription, Distance, VectorParams, Record

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

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

Expand Down
28 changes: 16 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
import createEmbeddings
from userInput import processUserInput

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

# Run the main function from createEmbeddings
createEmbeddings.embed_sample_functions()
# Run the main function from createEmbeddings
createEmbeddings.embed_sample_functions(repo_path)

# Run the main function from processUserInput
processUserInput.process_user_input()
# Run the main function from processUserInput
processUserInput.process_user_input()

# Create a test suite
suite = unittest.TestLoader().loadTestsFromModule(test_get_function_data)
# Create a test suite
suite = unittest.TestLoader().loadTestsFromModule(test_get_function_data)

# Run the tests with CustomTestRunner
test_get_function_data.CustomTestRunner().run(suite)
# Run the tests with CustomTestRunner
test_get_function_data.CustomTestRunner().run(suite)

if __name__ == '__main__':
# pass this variable if you want to run another repo than testRepo:
# repo_path='../inputData/elixirsolutions'
main()

0 comments on commit d09a2a5

Please sign in to comment.