Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,6 +37,13 @@ def init_app(api_key,
|
|
| 37 |
diffusion_model,
|
| 38 |
keyword_model,
|
| 39 |
dtype):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
console_logs = StringIO()
|
| 41 |
sys.stdout = console_logs
|
| 42 |
model_class = model_class.replace(" ","").lower()
|
|
@@ -84,6 +91,9 @@ def run_simulation(topic,
|
|
| 84 |
image_tokens=[],
|
| 85 |
news_company="CNN",
|
| 86 |
text_model_name="gpt-3.5-turbo-0301"):
|
|
|
|
|
|
|
|
|
|
| 87 |
console_logs = StringIO()
|
| 88 |
sys.stdout = console_logs
|
| 89 |
filename = topic.replace(" ", "-") + ".csv"
|
|
|
|
| 37 |
diffusion_model,
|
| 38 |
keyword_model,
|
| 39 |
dtype):
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
openai.api_key = api_key
|
| 43 |
+
openai.Model.list()
|
| 44 |
+
except Exception as e:
|
| 45 |
+
gr.Error(str(e))
|
| 46 |
+
|
| 47 |
console_logs = StringIO()
|
| 48 |
sys.stdout = console_logs
|
| 49 |
model_class = model_class.replace(" ","").lower()
|
|
|
|
| 91 |
image_tokens=[],
|
| 92 |
news_company="CNN",
|
| 93 |
text_model_name="gpt-3.5-turbo-0301"):
|
| 94 |
+
if topic == "":
|
| 95 |
+
gr.Error("Topic must not be empty")
|
| 96 |
+
|
| 97 |
console_logs = StringIO()
|
| 98 |
sys.stdout = console_logs
|
| 99 |
filename = topic.replace(" ", "-") + ".csv"
|