-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore_codebases.py
More file actions
26 lines (21 loc) · 932 Bytes
/
store_codebases.py
File metadata and controls
26 lines (21 loc) · 932 Bytes
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
from tinydb import TinyDB, Query
from codebase_rag import clone_repo, create_pinecone_namespace,remove_pinecone_index
import time
import shutil
import os
db = TinyDB('codebases.json')
codebase = Query()
def store_codebase(codebase_name,codebase_path):
#clone the database into directory and then create pinecone index. After creating pineconex index we can remove the clones directory, to not take up space.
clone_path_cwd = clone_repo(codebase_path)
create_pinecone_namespace(clone_path_cwd,codebase_path)
db.insert({'codebase_name':codebase_name,'codebase_path':codebase_path})
def get_codebases():
return db.all()
def get_codebase(code_base_name):
return db.search(codebase.codebase_name == code_base_name)
def remove_codebase(namespace):
#we will remove the pinecone index as well
remove_pinecone_index(namespace)
db.remove(codebase.codebase_path == namespace)
print(get_codebases())