Spaces:
Runtime error
Runtime error
Waiting for response
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
import json
|
|
|
|
| 4 |
|
| 5 |
st.title("Transaction Summarizer")
|
| 6 |
|
|
@@ -22,17 +23,32 @@ if st.button("Submit"):
|
|
| 22 |
json_data = json.dumps(data)
|
| 23 |
|
| 24 |
try:
|
| 25 |
-
# Send POST request
|
| 26 |
response = requests.post(url, headers=headers, data=json_data)
|
| 27 |
response.raise_for_status() # Raise an error for bad status codes
|
| 28 |
|
| 29 |
-
# Parse
|
| 30 |
result = response.json()
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
except requests.exceptions.RequestException as e:
|
| 34 |
st.error(f"An error occurred: {e}")
|
|
|
|
| 35 |
else:
|
| 36 |
if st.button("Reset"):
|
| 37 |
st.text_area("Enter your transactions (comma-separated)", value="")
|
| 38 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
+
import time
|
| 5 |
|
| 6 |
st.title("Transaction Summarizer")
|
| 7 |
|
|
|
|
| 23 |
json_data = json.dumps(data)
|
| 24 |
|
| 25 |
try:
|
| 26 |
+
# Send POST request to start processing
|
| 27 |
response = requests.post(url, headers=headers, data=json_data)
|
| 28 |
response.raise_for_status() # Raise an error for bad status codes
|
| 29 |
|
| 30 |
+
# Parse response to get job ID
|
| 31 |
result = response.json()
|
| 32 |
+
job_id = result['id']
|
| 33 |
+
st.write(f"Job ID: {job_id}")
|
| 34 |
+
|
| 35 |
+
# Keep checking status until it's no longer 'IN_QUEUE'
|
| 36 |
+
status_url = f"https://api.runpod.ai/v2/0wnm75vx5o77s1/status:{job_id}"
|
| 37 |
+
status = "IN_QUEUE"
|
| 38 |
+
while status == "IN_QUEUE":
|
| 39 |
+
status_response = requests.get(status_url, headers=headers)
|
| 40 |
+
status_data = status_response.json()
|
| 41 |
+
status = status_data.get('status', '')
|
| 42 |
+
time.sleep(5) # Adjust interval as needed
|
| 43 |
+
|
| 44 |
+
st.write(f"Current status: {status}")
|
| 45 |
+
|
| 46 |
+
# Once status changes, display final result
|
| 47 |
+
st.write("Final status:", status_data)
|
| 48 |
|
| 49 |
except requests.exceptions.RequestException as e:
|
| 50 |
st.error(f"An error occurred: {e}")
|
| 51 |
+
|
| 52 |
else:
|
| 53 |
if st.button("Reset"):
|
| 54 |
st.text_area("Enter your transactions (comma-separated)", value="")
|
|
|