-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (25 loc) · 1.17 KB
/
main.py
File metadata and controls
32 lines (25 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from oauth2client.client import GoogleCredentials
from google.colab import auth
from code_indexer import create_embeddings_for_folder
from initialize import initialize_searcher
from interactive import interactive_search
if __name__ == "__main__":
# 🔐 Authenticate with Google Drive
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
# 📂 Define the local code folder to index
folder_path = "downloaded_code"
# 📦 Create and upload embeddings to Google Drive (this is the call you asked about)
indexer, folder_id = create_embeddings_for_folder(folder_path, drive)
print(f"✅ Successfully created and saved embeddings for {len(indexer.file_paths)} files")
print(f"🗂️ All embedding files uploaded to Google Drive folder with ID: {folder_id}")
# 🔍 Start the search interface
searcher = initialize_searcher(folder_name="code_embeddings")
if searcher:
interactive_search(searcher)
else:
print("❌ Failed to initialize the Code Search System.")