Spaces:
Runtime error
Runtime error
Update backup.app.py
Browse files- backup.app.py +13 -2
backup.app.py
CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
|
|
2 |
import random
|
3 |
from transformers import pipeline
|
4 |
import pandas as pd
|
|
|
|
|
5 |
|
6 |
generator = pipeline('text-generation', model='gpt2')
|
7 |
max_length = 50
|
@@ -46,9 +48,18 @@ if st.button('Generate Prompt and Solution'):
|
|
46 |
prompt_text, prompt, solution = generate_prompt(option)
|
47 |
results.append([prompt_text, prompt, solution])
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
with open('results.txt', 'a') as f:
|
50 |
for result in results:
|
51 |
-
f.write(f"{result[0]}\t{result[1]}\t{result[2]}\n")
|
52 |
|
53 |
-
df = pd.read_csv('results.txt', sep='\t', header=None, names=['Input', 'Prompt', 'Solution'])
|
54 |
st.write(df)
|
|
|
2 |
import random
|
3 |
from transformers import pipeline
|
4 |
import pandas as pd
|
5 |
+
from datetime import datetime
|
6 |
+
import pytz
|
7 |
|
8 |
generator = pipeline('text-generation', model='gpt2')
|
9 |
max_length = 50
|
|
|
48 |
prompt_text, prompt, solution = generate_prompt(option)
|
49 |
results.append([prompt_text, prompt, solution])
|
50 |
|
51 |
+
user_timezone = st.text_input("Enter your timezone (e.g., 'America/New_York'):")
|
52 |
+
|
53 |
+
try:
|
54 |
+
tz = pytz.timezone(user_timezone)
|
55 |
+
current_time = datetime.now(tz).strftime('%Y-%m-%d %H:%M:%S %Z')
|
56 |
+
except Exception:
|
57 |
+
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
58 |
+
st.warning('Invalid timezone entered. Using the server timezone.')
|
59 |
+
|
60 |
with open('results.txt', 'a') as f:
|
61 |
for result in results:
|
62 |
+
f.write(f"{current_time}\t{result[0]}\t{result[1]}\t{result[2]}\n")
|
63 |
|
64 |
+
df = pd.read_csv('results.txt', sep='\t', header=None, names=['Timestamp', 'Input', 'Prompt', 'Solution'])
|
65 |
st.write(df)
|