Spaces:
Sleeping
Sleeping
Download ui/ui_app.py from Dewasheesh/HelpDev: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/Dewasheesh/HelpDev/resolve/main/ui/ui_app.py
- Command line
-
hf download hf://spaces/Dewasheesh/HelpDev/ui/ui_app.py
-
curl -L -o ui_app.py https://huggingface.co/spaces/Dewasheesh/HelpDev/resolve/main/ui/ui_app.py
1.21 kB
| import streamlit as st | |
| import requests | |
| API_CHAT_URL = "http://localhost:8000/chat/" | |
| API_UPLOAD_URL = "http://localhost:8000/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.") | |
| # 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}") | |