siddhartharya commited on
Commit
2bd7b24
1 Parent(s): 37185e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -6
app.py CHANGED
@@ -9,11 +9,7 @@ groq_api_key = os.getenv("GROQ_CLOUD_API_KEY")
9
 
10
  # Scraping function to fetch user public data (for demo purposes, we will simulate this)
11
  def fetch_public_data(name, dob, city):
12
- # Here, you could implement logic to fetch public data from sources like LinkedIn, GitHub, etc.
13
- # For simplicity, we will return dummy data to simulate a successful fetch.
14
- # You can implement web scraping or API integration to fetch real data.
15
- # Example scraping code can go here (or via LinkedIn API, etc.)
16
-
17
  bio = f"{name} is a software engineer from {city} with over 10 years of experience. Known for work in AI, cloud computing, and leadership in various engineering teams."
18
  return bio
19
 
@@ -42,4 +38,49 @@ def generate_email_from_groq(bio, company_name, role):
42
  def check_grammar(email_text):
43
  tool = language_tool_python.LanguageTool('en-US')
44
  matches = tool.check(email_text)
45
- corrected_text = language_tool_python
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Scraping function to fetch user public data (for demo purposes, we will simulate this)
11
  def fetch_public_data(name, dob, city):
12
+ # Simulate fetched bio data for demonstration purposes
 
 
 
 
13
  bio = f"{name} is a software engineer from {city} with over 10 years of experience. Known for work in AI, cloud computing, and leadership in various engineering teams."
14
  return bio
15
 
 
38
  def check_grammar(email_text):
39
  tool = language_tool_python.LanguageTool('en-US')
40
  matches = tool.check(email_text)
41
+ corrected_text = language_tool_python.utils.correct(email_text, matches)
42
+ return corrected_text
43
+
44
+ # Main function to create the email and allow for saving, editing, or copying
45
+ def create_email(name, dob, city, company_name, role):
46
+ # Step 1: Fetch public data based on user info
47
+ bio = fetch_public_data(name, dob, city)
48
+
49
+ # Step 2: Generate the email using Groq Cloud LLM
50
+ generated_email = generate_email_from_groq(bio, company_name, role)
51
+
52
+ # Step 3: Run grammar and tone check
53
+ polished_email = check_grammar(generated_email)
54
+
55
+ # Return the final polished email
56
+ return polished_email
57
+
58
+ # Define interface with Gradio
59
+ def gradio_ui():
60
+ # Define inputs
61
+ name_input = gr.Textbox(label="Name", placeholder="Enter your name")
62
+ dob_input = gr.Textbox(label="Date of Birth", placeholder="Enter your date of birth (YYYY-MM-DD)")
63
+ city_input = gr.Textbox(label="City", placeholder="Enter your city of residence")
64
+
65
+ company_name_input = gr.Textbox(label="Company Name", placeholder="Enter the name of the company you are applying to")
66
+ role_input = gr.Textbox(label="Role", placeholder="Enter the role you are applying for")
67
+
68
+ # Define output for the generated email
69
+ email_output = gr.Textbox(label="Generated Email", placeholder="Your generated email will appear here", lines=10)
70
+
71
+ # Create the Gradio interface
72
+ demo = gr.Interface(
73
+ fn=create_email, # Function to call when the user submits
74
+ inputs=[name_input, dob_input, city_input, company_name_input, role_input],
75
+ outputs=[email_output],
76
+ title="Email Writing AI Agent",
77
+ description="Generate a professional email for a job application by providing your basic info.",
78
+ allow_flagging="never" # Disable flagging
79
+ )
80
+
81
+ # Launch the Gradio app
82
+ demo.launch()
83
+
84
+ # Start the Gradio app when running the script
85
+ if __name__ == "__main__":
86
+ gradio_ui()