Spaces:
Sleeping
Sleeping
File size: 1,979 Bytes
3551cef b6fe984 ba6db8e b6fe984 ba6db8e b6fe984 bb22974 ba6db8e 5763adb ba6db8e |
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 52 53 54 55 |
import streamlit as st
import requests
# API_CHAT_URL = "http://localhost:8000/chat/"
# API_UPLOAD_URL = "http://localhost:8000/upload/"
API_CHAT_URL = "https://dewasheesh-helpdev.hf.space/chat/"
API_AM_CHAT_URL = "https://dewasheesh-helpdev.hf.space/am/chat/"
API_UPLOAD_URL = "https://dewasheesh-helpdev.hf.space/upload/"
st.title("π HelpDevelopers RAG Chatbot")
# PDF Upload Section
st.header("π€ Upload a PDF")
uploaded_file = st.file_uploader("Choose a PDF to upload", type="pdf")
if uploaded_file is not None:
if st.button("Upload"):
with st.spinner("Uploading..."):
files = {"file": (uploaded_file.name,
uploaded_file, "application/pdf")}
# res = requests.post(API_UPLOAD_URL, files=files)
# if res.status_code == 200:
# st.success(f"{uploaded_file.name} uploaded successfully!")
# else:
# st.error("Upload failed.")
st.success(f"{uploaded_file.name} uploaded successfully!")
# Chat Section
# st.header("π¬ Ask a Question")
# query = st.text_input("Your question:")
# if st.button("Submit"):
# if query:
# with st.spinner("Thinking..."):
# res = requests.post(API_CHAT_URL, json={
# "query": query, "top_k": 3})
# if res.status_code == 200:
# st.success(res.json().get("answer", "No response."))
# else:
# st.error(f"Error: {res.text}")
# Chat Section
st.header("π¬ Ask a CAM Question")
query = st.text_input("Your question:")
if st.button("Submit"):
if query:
with st.spinner("Namaskar.....Thinking..."):
res = requests.post(API_AM_CHAT_URL, json={
"query": query, "top_k": 30})
if res.status_code == 200:
st.success(res.json().get("answer", "No response."))
else:
st.error(f"Error: {res.text}")
|