Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
-
from
|
4 |
import os
|
5 |
from datetime import datetime # Import datetime for date validation
|
6 |
|
7 |
-
# Initialize
|
8 |
-
|
9 |
|
10 |
# Load Groq Cloud API key securely from environment variables
|
11 |
groq_api_key = os.getenv("GROQ_CLOUD_API_KEY")
|
@@ -52,11 +52,10 @@ def generate_email_from_groq(bio, company_name, role):
|
|
52 |
print(f"Error: {response.status_code}, {response.text}")
|
53 |
return "Error generating email. Please check your API key or try again later."
|
54 |
|
55 |
-
# Grammar and Tone Checker Function using
|
56 |
def check_grammar(email_text):
|
57 |
-
|
58 |
-
|
59 |
-
return corrected_sentences[0] if corrected_sentences else email_text
|
60 |
|
61 |
# Function to validate the DOB format (DD-MM-YYYY)
|
62 |
def validate_dob(dob):
|
@@ -83,7 +82,7 @@ def create_email(name, dob, city, company_name, role, email, phone):
|
|
83 |
# Step 3: Add the user's email, phone number, and LinkedIn profile to the signature
|
84 |
signature = f"\n\nBest regards,\n{name}\nEmail: {email}\nPhone: {phone}\nLinkedIn: {linkedin_profile}"
|
85 |
|
86 |
-
# Step 4: Run grammar and tone check using
|
87 |
polished_email = check_grammar(generated_email + signature)
|
88 |
|
89 |
# Return the final polished email with the signature
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
from gingerit.gingerit import GingerIt # Import GingerIt for grammar correction
|
4 |
import os
|
5 |
from datetime import datetime # Import datetime for date validation
|
6 |
|
7 |
+
# Initialize GingerIt parser
|
8 |
+
ginger_parser = GingerIt()
|
9 |
|
10 |
# Load Groq Cloud API key securely from environment variables
|
11 |
groq_api_key = os.getenv("GROQ_CLOUD_API_KEY")
|
|
|
52 |
print(f"Error: {response.status_code}, {response.text}")
|
53 |
return "Error generating email. Please check your API key or try again later."
|
54 |
|
55 |
+
# Grammar and Tone Checker Function using GingerIt
|
56 |
def check_grammar(email_text):
|
57 |
+
corrected_text = ginger_parser.parse(email_text)["result"]
|
58 |
+
return corrected_text
|
|
|
59 |
|
60 |
# Function to validate the DOB format (DD-MM-YYYY)
|
61 |
def validate_dob(dob):
|
|
|
82 |
# Step 3: Add the user's email, phone number, and LinkedIn profile to the signature
|
83 |
signature = f"\n\nBest regards,\n{name}\nEmail: {email}\nPhone: {phone}\nLinkedIn: {linkedin_profile}"
|
84 |
|
85 |
+
# Step 4: Run grammar and tone check using GingerIt
|
86 |
polished_email = check_grammar(generated_email + signature)
|
87 |
|
88 |
# Return the final polished email with the signature
|