forked from TheAK94/RAG-Codebase-Explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (29 loc) · 1.04 KB
/
Copy pathmain.py
File metadata and controls
51 lines (29 loc) · 1.04 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from ingest.clone_repo import clone_repo
from ingest.load_files import load_code_files
from ingest.chunk_code import chunk_code_documents
from embeddings.embedder import store_embeddings
from rag.generator import answer_question
def ingest_repo(repo_url):
print("\nCloning repository...")
repo_path = clone_repo(repo_url)
print("\nLoading files...")
docs = load_code_files(repo_path)
print("Files loaded:", len(docs))
print("\nChunking code...")
chunks = chunk_code_documents(docs)
print("Total chunks:", len(chunks))
print("\nCreating embeddings...")
store_embeddings(chunks)
print("\nRepository indexed successfully!")
def ask_questions():
while True:
question = input("\nAsk about the repository (or 'exit'): ")
if question.lower() == "exit":
break
answer = answer_question(question)
print("\nAI Answer:\n")
print(answer)
if __name__ == "__main__":
repo_url = input("Enter GitHub repo URL: ")
ingest_repo(repo_url)
ask_questions()