Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,42 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
import time
|
|
|
|
|
|
|
| 3 |
time.sleep(3)
|
| 4 |
|
| 5 |
-
|
| 6 |
-
import requests
|
| 7 |
|
| 8 |
st.title("🧠 Codebase RAG Assistant")
|
| 9 |
|
| 10 |
repo_url = st.text_input("GitHub Repository URL")
|
| 11 |
|
| 12 |
if st.button("Index Repository"):
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
)
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
question = st.text_input("Ask a question about the codebase")
|
| 21 |
|
| 22 |
if st.button("Ask"):
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
import time
|
| 4 |
+
|
| 5 |
+
# Wait for FastAPI backend to start
|
| 6 |
time.sleep(3)
|
| 7 |
|
| 8 |
+
BACKEND_URL = "http://127.0.0.1:8000"
|
|
|
|
| 9 |
|
| 10 |
st.title("🧠 Codebase RAG Assistant")
|
| 11 |
|
| 12 |
repo_url = st.text_input("GitHub Repository URL")
|
| 13 |
|
| 14 |
if st.button("Index Repository"):
|
| 15 |
+
response = requests.post(
|
| 16 |
+
f"{BACKEND_URL}/load",
|
| 17 |
+
params={"repo_url": repo_url}
|
| 18 |
+
)
|
| 19 |
+
if response.status_code == 200:
|
| 20 |
+
st.success("Repository indexed successfully!")
|
| 21 |
+
else:
|
| 22 |
+
st.error("Failed to index repository")
|
| 23 |
|
| 24 |
question = st.text_input("Ask a question about the codebase")
|
| 25 |
|
| 26 |
if st.button("Ask"):
|
| 27 |
+
response = requests.get(
|
| 28 |
+
f"{BACKEND_URL}/ask",
|
| 29 |
+
params={"question": question}
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
if response.status_code == 200:
|
| 33 |
+
data = response.json()
|
| 34 |
+
|
| 35 |
+
st.write("### Answer")
|
| 36 |
+
st.write(data["answer"])
|
| 37 |
+
|
| 38 |
+
st.write("### Sources")
|
| 39 |
+
for src in data["sources"]:
|
| 40 |
+
st.write(src)
|
| 41 |
+
else:
|
| 42 |
+
st.error("Failed to get answer from backend")
|