siddhartharya commited on
Commit
09696f6
·
verified ·
1 Parent(s): c3d82ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -20
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import requests
3
  import os
4
- from datetime import datetime # Import datetime for date validation
5
 
6
  # Load API keys securely from environment variables
7
  proxycurl_api_key = os.getenv("PROXYCURL_API_KEY") # Add your Proxycurl API key to your environment variables
@@ -67,27 +66,13 @@ def generate_and_correct_email(bio, company_name, role):
67
  print(f"Error: {response.status_code}, {response.text}")
68
  return "Error generating email. Please check your API key or try again later."
69
 
70
- # Function to validate the DOB format (DD-MM-YYYY)
71
- def validate_dob(dob):
72
- try:
73
- # Attempt to parse the DOB to the expected format
74
- datetime.strptime(dob, "%d-%m-%Y")
75
- return True
76
- except ValueError:
77
- # Return False if the format is invalid
78
- return False
79
-
80
  # Main function to create the email and allow for saving, editing, or copying
81
- def create_email(name, dob, city, company_name, role, email, phone, linkedin_profile_url):
82
- # Validate the DOB format (DD-MM-YYYY)
83
- if not validate_dob(dob):
84
- return "Invalid Date of Birth format. Please use DD-MM-YYYY."
85
-
86
  # Step 1: Fetch LinkedIn profile using Proxycurl API if LinkedIn URL is provided
87
  if linkedin_profile_url:
88
  bio = get_linkedin_profile_via_proxycurl(linkedin_profile_url)
89
  else:
90
- bio = f"{name} is a professional in {city}." # Default bio if no LinkedIn URL is provided
91
 
92
  # Step 2: Generate the email using Groq Cloud LLM
93
  generated_email = generate_and_correct_email(bio, company_name, role)
@@ -106,8 +91,6 @@ def create_email(name, dob, city, company_name, role, email, phone, linkedin_pro
106
  def gradio_ui():
107
  # Define inputs
108
  name_input = gr.Textbox(label="Name", placeholder="Enter your name")
109
- dob_input = gr.Textbox(label="Date of Birth", placeholder="Enter your date of birth (DD-MM-YYYY)")
110
- city_input = gr.Textbox(label="City", placeholder="Enter your city of residence")
111
 
112
  company_name_input = gr.Textbox(label="Company Name", placeholder="Enter the name of the company you are applying to")
113
  role_input = gr.Textbox(label="Role", placeholder="Enter the role you are applying for")
@@ -122,7 +105,7 @@ def gradio_ui():
122
  # Create the Gradio interface
123
  demo = gr.Interface(
124
  fn=create_email, # Function to call when the user submits
125
- inputs=[name_input, dob_input, city_input, company_name_input, role_input, email_input, phone_input, linkedin_input],
126
  outputs=[email_output],
127
  title="Email Writing AI Agent",
128
  description="Generate a professional email for a job application by providing your basic info.",
 
1
  import gradio as gr
2
  import requests
3
  import os
 
4
 
5
  # Load API keys securely from environment variables
6
  proxycurl_api_key = os.getenv("PROXYCURL_API_KEY") # Add your Proxycurl API key to your environment variables
 
66
  print(f"Error: {response.status_code}, {response.text}")
67
  return "Error generating email. Please check your API key or try again later."
68
 
 
 
 
 
 
 
 
 
 
 
69
  # Main function to create the email and allow for saving, editing, or copying
70
+ def create_email(name, company_name, role, email, phone, linkedin_profile_url):
 
 
 
 
71
  # Step 1: Fetch LinkedIn profile using Proxycurl API if LinkedIn URL is provided
72
  if linkedin_profile_url:
73
  bio = get_linkedin_profile_via_proxycurl(linkedin_profile_url)
74
  else:
75
+ bio = f"{name} is a professional." # Default bio if no LinkedIn URL is provided
76
 
77
  # Step 2: Generate the email using Groq Cloud LLM
78
  generated_email = generate_and_correct_email(bio, company_name, role)
 
91
  def gradio_ui():
92
  # Define inputs
93
  name_input = gr.Textbox(label="Name", placeholder="Enter your name")
 
 
94
 
95
  company_name_input = gr.Textbox(label="Company Name", placeholder="Enter the name of the company you are applying to")
96
  role_input = gr.Textbox(label="Role", placeholder="Enter the role you are applying for")
 
105
  # Create the Gradio interface
106
  demo = gr.Interface(
107
  fn=create_email, # Function to call when the user submits
108
+ inputs=[name_input, company_name_input, role_input, email_input, phone_input, linkedin_input],
109
  outputs=[email_output],
110
  title="Email Writing AI Agent",
111
  description="Generate a professional email for a job application by providing your basic info.",