ozzyable commited on
Commit
033c928
·
1 Parent(s): 789a0ad

Waiting for response

Browse files
Files changed (1) hide show
  1. app.py +31 -7
app.py CHANGED
@@ -3,12 +3,14 @@ import requests
3
  import json
4
  import time
5
 
6
- st.title("Transaction Summarizer v2")
7
 
8
- transactions = st.text_area("Enter your transactions (comma-separated)").split(',')
9
- transactions = [i.strip() for i in transactions if i.strip()]
 
10
 
11
- if st.button("Submit"):
 
12
  url = "https://api.runpod.ai/v2/0wnm75vx5o77s1/run"
13
  headers = {
14
  'Content-Type': 'application/json',
@@ -16,7 +18,7 @@ if st.button("Submit"):
16
  }
17
  data = {
18
  'input': {
19
- 'transaction': transactions
20
  }
21
  }
22
 
@@ -30,7 +32,7 @@ if st.button("Submit"):
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}"
@@ -43,12 +45,34 @@ if st.button("Submit"):
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="")
 
3
  import json
4
  import time
5
 
6
+ st.title("Transaction Summarizer")
7
 
8
+ # Input for submitting new transactions
9
+ new_transactions = st.text_area("Enter your transactions (comma-separated)").split(',')
10
+ new_transactions = [i.strip() for i in new_transactions if i.strip()]
11
 
12
+ # Submit button for new transactions
13
+ if st.button("Submit New Transactions"):
14
  url = "https://api.runpod.ai/v2/0wnm75vx5o77s1/run"
15
  headers = {
16
  'Content-Type': 'application/json',
 
18
  }
19
  data = {
20
  'input': {
21
+ 'transaction': new_transactions
22
  }
23
  }
24
 
 
32
  # Parse response to get job ID
33
  result = response.json()
34
  job_id = result['id']
35
+ st.write(f"New Job ID: {job_id}")
36
 
37
  # Keep checking status until it's no longer 'IN_QUEUE'
38
  status_url = f"https://api.runpod.ai/v2/0wnm75vx5o77s1/status:{job_id}"
 
45
 
46
  st.write(f"Current status: {status}")
47
 
48
+ # Once status changes, display final status
49
  st.write("Final status:", status_data)
50
 
51
  except requests.exceptions.RequestException as e:
52
  st.error(f"An error occurred: {e}")
53
 
54
+ # Input and button for fetching status or result by job ID
55
+ st.subheader("Fetch Status or Result by Job ID")
56
+ job_id_input = st.text_input("Enter Job ID")
57
+
58
+ if st.button("Fetch Status or Result"):
59
+ if job_id_input:
60
+ try:
61
+ status_url = f"https://api.runpod.ai/v2/0wnm75vx5o77s1/status:{job_id_input}"
62
+ headers = {
63
+ 'Authorization': 'API_KEY'
64
+ }
65
+
66
+ # Fetch status or result based on job ID
67
+ status_response = requests.get(status_url, headers=headers)
68
+ status_data = status_response.json()
69
+
70
+ # Display status or result
71
+ st.write("Status or Result:", status_data)
72
+
73
+ except requests.exceptions.RequestException as e:
74
+ st.error(f"An error occurred: {e}")
75
+
76
  else:
77
  if st.button("Reset"):
78
  st.text_area("Enter your transactions (comma-separated)", value="")