| import streamlit as st |
| import requests |
|
|
| |
| API_URL = "https://startrz-proagents.hf.space/api/v1/prediction/5e21b535-6568-4acb-94a7-076a6996181e" |
|
|
| |
| def query_api(question): |
| payload = {"question": question} |
| try: |
| response = requests.post(API_URL, json=payload) |
| response.raise_for_status() |
| return response.json() |
| except requests.exceptions.RequestException as e: |
| return {"error": str(e)} |
|
|
| |
| st.title("API Query App") |
|
|
| |
| user_question = st.text_input("Ask a question:") |
|
|
| |
| if st.button("Submit"): |
| if user_question: |
| with st.spinner("Fetching response..."): |
| output = query_api(user_question) |
| if "error" in output: |
| st.error(f"Error: {output['error']}") |
| else: |
| |
| st.subheader("Response:") |
| st.write(output) |
| else: |
| st.warning("Please enter a question before submitting.") |
|
|
|
|