abhlash commited on
Commit
76b265a
·
1 Parent(s): 0979a5b

updated the app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -49,7 +49,6 @@ except Exception as e:
49
  tokenizer = AutoTokenizer.from_pretrained(fallback_model)
50
  model = AutoModelForCausalLM.from_pretrained(fallback_model)
51
 
52
- # Function to generate a formatted email
53
  def generate_email(recipient_name, recipient_email, industry, recipient_role, details):
54
  prompt = (
55
  f"Write a short professional email to {recipient_name}, "
@@ -85,10 +84,23 @@ def generate_email(recipient_name, recipient_email, industry, recipient_role, de
85
 
86
  # Format the email
87
  formatted_email = f"""\
88
- To: {recipient_name}
 
 
 
 
 
 
 
 
 
89
  """
90
  return formatted_email
91
 
 
 
 
 
92
  # Create Gradio interface
93
  iface = gr.Interface(
94
  fn=generate_email,
@@ -99,11 +111,15 @@ iface = gr.Interface(
99
  gr.Textbox(lines=1, label="Recipient Role (e.g., Manager, Director)"),
100
  gr.Textbox(lines=5, label="Personal/Company Details (e.g., name, product)"),
101
  ],
102
- outputs="text",
103
  title="EmailGenie: AI-Powered Email Generator",
104
- description="Automate the creation of personalized emails to increase engagement and conversion rates. Enter details to generate tailored emails."
105
  )
106
 
107
  # Launch the app
108
  if __name__ == '__main__':
109
  iface.launch()
 
 
 
 
 
49
  tokenizer = AutoTokenizer.from_pretrained(fallback_model)
50
  model = AutoModelForCausalLM.from_pretrained(fallback_model)
51
 
 
52
  def generate_email(recipient_name, recipient_email, industry, recipient_role, details):
53
  prompt = (
54
  f"Write a short professional email to {recipient_name}, "
 
84
 
85
  # Format the email
86
  formatted_email = f"""\
87
+ To: {recipient_name} <{recipient_email}>
88
+ Subject: Collaboration Opportunity
89
+
90
+ {email_body}
91
+
92
+ Best regards,
93
+ Jane Smith
94
+ Android Developer
95
+ Albertsons
96
+ [Your Contact Information]
97
  """
98
  return formatted_email
99
 
100
+ except Exception as e:
101
+ logging.error(f"Error generating email: {str(e)}")
102
+ return f"Error generating email: {str(e)}"
103
+
104
  # Create Gradio interface
105
  iface = gr.Interface(
106
  fn=generate_email,
 
111
  gr.Textbox(lines=1, label="Recipient Role (e.g., Manager, Director)"),
112
  gr.Textbox(lines=5, label="Personal/Company Details (e.g., name, product)"),
113
  ],
114
+ outputs=gr.Textbox(lines=10, label="Generated Email or Error Message"),
115
  title="EmailGenie: AI-Powered Email Generator",
116
+ description="Automate the creation of personalized emails. Enter details to generate tailored emails."
117
  )
118
 
119
  # Launch the app
120
  if __name__ == '__main__':
121
  iface.launch()
122
+
123
+ # Log model information
124
+ logging.info(f"Model name: {model.config._name_or_path}")
125
+ logging.info(f"Model parameters: {model.num_parameters()}")