SoSa123456 commited on
Commit
7243644
1 Parent(s): 3bfdf65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
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")
@@ -12,6 +12,13 @@ def generate_script(host_name, listener_location, causes_climate_change, co2_lev
12
  TOPIC, DESCRIPTION):
13
  try:
14
  # Variables and template definitions...
 
 
 
 
 
 
 
15
 
16
  # Combine templates based on the DESCRIPTION
17
  prompt_template = f"""{introduction_template} {causes_template} {effects_template} {solutions_template} {role_template} {action_template} {summary_template}
@@ -38,7 +45,7 @@ def generate_script(host_name, listener_location, causes_climate_change, co2_lev
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
 
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")
 
12
  TOPIC, DESCRIPTION):
13
  try:
14
  # Variables and template definitions...
15
+ introduction_template = f"{host_name}, good morning! This is {listener_location}'s local radio station. Today we're talking about an issue that affects us all - {TOPIC}. It's a pressing issue that requires our immediate attention..."
16
+ causes_template = f"The causes of {TOPIC} are {causes_climate_change}. Today, the level of CO2 in our atmosphere is {co2_level}, which is concerning..."
17
+ effects_template = f"These activities result in {effects_climate_change}, leading to drastic changes in our environment. For instance, sea levels are rising at a rate of {sea_level_rise} per year, and global temperatures are increasing at a rate of {warming_rate} per decade..."
18
+ solutions_template = f"But don't worry, there are solutions. {potential_solutions} are all steps we can take to mitigate these effects..."
19
+ role_template = f"Each one of us plays a role in combating {TOPIC}. Even small actions can make a big difference. In fact, our location, {listener_location}, is particularly vulnerable to {TOPIC} due to its geographical features..."
20
+ action_template = f"So, {listener_location}, why wait? Start taking steps today towards a greener future. Support local businesses that prioritize sustainability, reduce your carbon footprint, and voice your opinion to policy makers..."
21
+ summary_template = f"In conclusion, {TOPIC} is a serious issue that requires our immediate attention. But by understanding its causes, effects, and potential solutions, we can all play a part in mitigating its impact. Thank you for joining us today, and remember, every small action counts!"
22
 
23
  # Combine templates based on the DESCRIPTION
24
  prompt_template = f"""{introduction_template} {causes_template} {effects_template} {solutions_template} {role_template} {action_template} {summary_template}
 
45
  error_message = f"Error: {e}"
46
 
47
  # Save error log to a file
48
+ with open("error_log.txt", "a") as log_file:
49
  log_file.write(error_message + "\n")
50
 
51
  return error_message