aman1762 commited on
Commit
1d49922
·
verified ·
1 Parent(s): 4fa7713

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
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
- response = requests.post(
15
  f"{BACKEND_URL}/load",
16
  params={"repo_url": repo_url}
17
  )
18
- if response.status_code == 200:
19
  st.success("Repository indexed successfully!")
20
  else:
21
- st.error("Failed to index repository")
22
 
23
  question = st.text_input("Ask a question about the codebase")
24
 
25
- if st.button("Ask"):
26
- response = requests.get(
 
 
27
  f"{BACKEND_URL}/ask",
28
  params={"question": question}
29
  )
30
 
31
- if response.status_code == 200:
32
- data = response.json()
 
 
33
 
34
- st.write("### Answer")
35
  st.write(data["answer"])
36
 
37
- st.write("### Sources")
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)