Spaces:
Runtime error
Runtime error
code for tinyllama api
Browse files
app.py
CHANGED
@@ -1,6 +1,38 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
transactions = st.text_area("Enter your transactions").split(',')
|
4 |
-
transactions = [i.strip() for i in transactions]
|
5 |
-
if st.button("Reset", type="primary"):
|
6 |
-
st.write(f"transaction: {transactions}")
|
|
|
1 |
import streamlit as st
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
+
|
5 |
+
st.title("Transaction Summarizer")
|
6 |
+
|
7 |
+
transactions = st.text_area("Enter your transactions (comma-separated)").split(',')
|
8 |
+
transactions = [i.strip() for i in transactions if i.strip()]
|
9 |
+
|
10 |
+
if st.button("Submit"):
|
11 |
+
url = "https://api.runpod.ai/v2/0wnm75vx5o77s1/run"
|
12 |
+
headers = {
|
13 |
+
'Content-Type': 'application/json',
|
14 |
+
'Authorization': 'API_KEY'
|
15 |
+
}
|
16 |
+
data = {
|
17 |
+
'input': {
|
18 |
+
'transaction': transactions
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
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 and display response
|
30 |
+
result = response.json()
|
31 |
+
st.write("Response:", result)
|
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 |
|
|
|
|
|
|
|
|