Update app.py
Browse files
app.py
CHANGED
|
@@ -11,31 +11,33 @@ st.title("🧠 Codebase RAG Assistant")
|
|
| 11 |
repo_url = st.text_input("GitHub Repository URL")
|
| 12 |
|
| 13 |
if st.button("Index Repository"):
|
| 14 |
-
|
| 15 |
f"{BACKEND_URL}/load",
|
| 16 |
params={"repo_url": repo_url}
|
| 17 |
)
|
| 18 |
-
if
|
| 19 |
st.success("Repository indexed successfully!")
|
| 20 |
else:
|
| 21 |
-
st.error("
|
| 22 |
|
| 23 |
question = st.text_input("Ask a question about the codebase")
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
f"{BACKEND_URL}/ask",
|
| 28 |
params={"question": question}
|
| 29 |
)
|
| 30 |
|
| 31 |
-
if
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
st.
|
| 35 |
st.write(data["answer"])
|
| 36 |
|
| 37 |
-
st.
|
| 38 |
for src in data["sources"]:
|
| 39 |
st.write(src)
|
| 40 |
-
else:
|
| 41 |
-
st.error("Failed to get answer from backend")
|
|
|
|
| 11 |
repo_url = st.text_input("GitHub Repository URL")
|
| 12 |
|
| 13 |
if st.button("Index Repository"):
|
| 14 |
+
r = requests.post(
|
| 15 |
f"{BACKEND_URL}/load",
|
| 16 |
params={"repo_url": repo_url}
|
| 17 |
)
|
| 18 |
+
if r.status_code == 200:
|
| 19 |
st.success("Repository indexed successfully!")
|
| 20 |
else:
|
| 21 |
+
st.error("Indexing failed")
|
| 22 |
|
| 23 |
question = st.text_input("Ask a question about the codebase")
|
| 24 |
|
| 25 |
+
ask_clicked = st.button("Ask")
|
| 26 |
+
|
| 27 |
+
if ask_clicked:
|
| 28 |
+
r = requests.get(
|
| 29 |
f"{BACKEND_URL}/ask",
|
| 30 |
params={"question": question}
|
| 31 |
)
|
| 32 |
|
| 33 |
+
if r.status_code != 200:
|
| 34 |
+
st.error("Backend error")
|
| 35 |
+
else:
|
| 36 |
+
data = r.json()
|
| 37 |
|
| 38 |
+
st.markdown("### Answer")
|
| 39 |
st.write(data["answer"])
|
| 40 |
|
| 41 |
+
st.markdown("### Sources")
|
| 42 |
for src in data["sources"]:
|
| 43 |
st.write(src)
|
|
|
|
|
|