Spaces:
Runtime error
Runtime error
Commit ·
3bfdf65
1
Parent(s): cc2185f
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import warnings
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
warnings.filterwarnings('ignore')
|
| 6 |
|
| 7 |
# Initialize the language model
|
| 8 |
generator = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
@@ -30,13 +30,18 @@ def generate_script(host_name, listener_location, causes_climate_change, co2_lev
|
|
| 30 |
# Check if any section exceeds the target word count
|
| 31 |
for i, count in enumerate(word_counts):
|
| 32 |
if count > 200:
|
| 33 |
-
|
| 34 |
|
| 35 |
return script
|
| 36 |
|
| 37 |
except Exception as e:
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
# Gradio interface setup...
|
| 42 |
iface = gr.Interface(fn=generate_script,
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
#warnings.filterwarnings('ignore')
|
| 6 |
|
| 7 |
# Initialize the language model
|
| 8 |
generator = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
|
|
| 30 |
# Check if any section exceeds the target word count
|
| 31 |
for i, count in enumerate(word_counts):
|
| 32 |
if count > 200:
|
| 33 |
+
return f"Warning: Section {i + 1} exceeds the target word count. You may need to shorten this section."
|
| 34 |
|
| 35 |
return script
|
| 36 |
|
| 37 |
except Exception as e:
|
| 38 |
+
error_message = f"Error: {e}"
|
| 39 |
+
|
| 40 |
+
# Save error log to a file
|
| 41 |
+
with open("./error_log.txt", "a") as log_file:
|
| 42 |
+
log_file.write(error_message + "\n")
|
| 43 |
+
|
| 44 |
+
return error_message
|
| 45 |
|
| 46 |
# Gradio interface setup...
|
| 47 |
iface = gr.Interface(fn=generate_script,
|