Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +20 -5
src/streamlit_app.py
CHANGED
|
@@ -5,6 +5,7 @@ import requests
|
|
| 5 |
# API_UPLOAD_URL = "http://localhost:8000/upload/"
|
| 6 |
|
| 7 |
API_CHAT_URL = "https://dewasheesh-helpdev.hf.space/chat/"
|
|
|
|
| 8 |
API_UPLOAD_URL = "https://dewasheesh-helpdev.hf.space/upload/"
|
| 9 |
|
| 10 |
|
|
@@ -19,11 +20,12 @@ if uploaded_file is not None:
|
|
| 19 |
with st.spinner("Uploading..."):
|
| 20 |
files = {"file": (uploaded_file.name,
|
| 21 |
uploaded_file, "application/pdf")}
|
| 22 |
-
res = requests.post(API_UPLOAD_URL, files=files)
|
| 23 |
-
if res.status_code == 200:
|
| 24 |
-
|
| 25 |
-
else:
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
# Chat Section
|
| 29 |
st.header("💬 Ask a Question")
|
|
@@ -37,3 +39,16 @@ if st.button("Submit"):
|
|
| 37 |
st.success(res.json().get("answer", "No response."))
|
| 38 |
else:
|
| 39 |
st.error(f"Error: {res.text}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# API_UPLOAD_URL = "http://localhost:8000/upload/"
|
| 6 |
|
| 7 |
API_CHAT_URL = "https://dewasheesh-helpdev.hf.space/chat/"
|
| 8 |
+
API_AM_CHAT_URL = "https://dewasheesh-helpdev.hf.space/am/chat/"
|
| 9 |
API_UPLOAD_URL = "https://dewasheesh-helpdev.hf.space/upload/"
|
| 10 |
|
| 11 |
|
|
|
|
| 20 |
with st.spinner("Uploading..."):
|
| 21 |
files = {"file": (uploaded_file.name,
|
| 22 |
uploaded_file, "application/pdf")}
|
| 23 |
+
# res = requests.post(API_UPLOAD_URL, files=files)
|
| 24 |
+
# if res.status_code == 200:
|
| 25 |
+
# st.success(f"{uploaded_file.name} uploaded successfully!")
|
| 26 |
+
# else:
|
| 27 |
+
# st.error("Upload failed.")
|
| 28 |
+
st.success(f"{uploaded_file.name} uploaded successfully!")
|
| 29 |
|
| 30 |
# Chat Section
|
| 31 |
st.header("💬 Ask a Question")
|
|
|
|
| 39 |
st.success(res.json().get("answer", "No response."))
|
| 40 |
else:
|
| 41 |
st.error(f"Error: {res.text}")
|
| 42 |
+
|
| 43 |
+
# Chat Section
|
| 44 |
+
st.header("💬 Ask a CAM Question")
|
| 45 |
+
query = st.text_input("Your question:")
|
| 46 |
+
if st.button("Submit"):
|
| 47 |
+
if query:
|
| 48 |
+
with st.spinner("Namaskar.....Thinking..."):
|
| 49 |
+
res = requests.post(API_AM_CHAT_URL, json={
|
| 50 |
+
"query": query, "top_k": 3})
|
| 51 |
+
if res.status_code == 200:
|
| 52 |
+
st.success(res.json().get("answer", "No response."))
|
| 53 |
+
else:
|
| 54 |
+
st.error(f"Error: {res.text}")
|