Spaces:
Runtime error
Runtime error
Commit
·
4f5812d
1
Parent(s):
a0364bb
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,17 +10,7 @@ import gradio as gr
|
|
| 10 |
# Initialize the language model
|
| 11 |
generator = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 12 |
|
| 13 |
-
def generate_script(host_name, listener_location, causes_climate_change, co2_level, effects_climate_change, sea_level_rise, warming_rate, potential_solutions, individual_role, call_to_action):
|
| 14 |
-
# Default values for variables if not provided by the user
|
| 15 |
-
causes_climate_change = causes_climate_change or "default_causes"
|
| 16 |
-
co2_level = co2_level or 400
|
| 17 |
-
effects_climate_change = effects_climate_change or "default_effects"
|
| 18 |
-
sea_level_rise = sea_level_rise or 2.0
|
| 19 |
-
warming_rate = warming_rate or 1.5
|
| 20 |
-
potential_solutions = potential_solutions or "default_solutions"
|
| 21 |
-
individual_role = individual_role or "default_role"
|
| 22 |
-
call_to_action = call_to_action or "default_action"
|
| 23 |
-
|
| 24 |
# Variables
|
| 25 |
prompt_template = f"""INTRODUCTION: {host_name}, good morning! This is {listener_location}'s local radio station. Today we're talking about an issue that affects us all - climate change. It's a pressing issue that requires our immediate attention...
|
| 26 |
CAUSES OF CLIMATE CHANGE: The causes of climate change are {causes_climate_change}. Today, the level of CO2 in our atmosphere is {co2_level}, which is concerning...
|
|
@@ -51,19 +41,22 @@ def generate_script(host_name, listener_location, causes_climate_change, co2_lev
|
|
| 51 |
|
| 52 |
return script, debug_output
|
| 53 |
|
| 54 |
-
# Create
|
| 55 |
-
|
| 56 |
-
gr.Textbox(label="Host Name"),
|
| 57 |
-
gr.Textbox(label="Listener Location"),
|
| 58 |
-
gr.Textbox(label="Causes Climate Change",
|
| 59 |
-
gr.Number(label="CO2 Level",
|
| 60 |
-
gr.Textbox(label="Effects Climate Change",
|
| 61 |
-
gr.Number(label="Sea Level Rise",
|
| 62 |
-
gr.Number(label="Warming Rate",
|
| 63 |
-
gr.Textbox(label="Potential Solutions",
|
| 64 |
-
gr.Textbox(label="Individual Role",
|
| 65 |
-
gr.Textbox(label="Call To Action",
|
| 66 |
-
]
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
# Launch the interface
|
| 69 |
iface.launch()
|
|
|
|
| 10 |
# Initialize the language model
|
| 11 |
generator = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 12 |
|
| 13 |
+
def generate_script(host_name, listener_location, causes_climate_change="", co2_level=400, effects_climate_change="", sea_level_rise=2.0, warming_rate=1.5, potential_solutions="", individual_role="", call_to_action=""):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Variables
|
| 15 |
prompt_template = f"""INTRODUCTION: {host_name}, good morning! This is {listener_location}'s local radio station. Today we're talking about an issue that affects us all - climate change. It's a pressing issue that requires our immediate attention...
|
| 16 |
CAUSES OF CLIMATE CHANGE: The causes of climate change are {causes_climate_change}. Today, the level of CO2 in our atmosphere is {co2_level}, which is concerning...
|
|
|
|
| 41 |
|
| 42 |
return script, debug_output
|
| 43 |
|
| 44 |
+
# Create Gradio inputs with default values
|
| 45 |
+
inputs = [
|
| 46 |
+
gr.Textbox(label="Host Name", default=""),
|
| 47 |
+
gr.Textbox(label="Listener Location", default=""),
|
| 48 |
+
gr.Textbox(label="Causes Climate Change", default=""),
|
| 49 |
+
gr.Number(label="CO2 Level", default=400),
|
| 50 |
+
gr.Textbox(label="Effects Climate Change", default=""),
|
| 51 |
+
gr.Number(label="Sea Level Rise", default=2.0),
|
| 52 |
+
gr.Number(label="Warming Rate", default=1.5),
|
| 53 |
+
gr.Textbox(label="Potential Solutions", default=""),
|
| 54 |
+
gr.Textbox(label="Individual Role", default=""),
|
| 55 |
+
gr.Textbox(label="Call To Action", default="")
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
+
# Create Gradio interface
|
| 59 |
+
iface = gr.Interface(fn=generate_script, inputs=inputs, outputs=["text", "text"])
|
| 60 |
|
| 61 |
# Launch the interface
|
| 62 |
iface.launch()
|