Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from bs4 import BeautifulSoup
|
|
5 |
import os
|
6 |
from datetime import datetime # Import datetime for date validation
|
7 |
|
8 |
-
# Load Groq Cloud API key from
|
9 |
groq_api_key = os.getenv("GROQ_CLOUD_API_KEY")
|
10 |
|
11 |
# Scraping function to fetch user public data (for demo purposes, we will simulate this)
|
@@ -20,14 +20,15 @@ def fetch_public_data(name, dob, city):
|
|
20 |
|
21 |
# Helper function to call Groq Cloud LLM API to generate email
|
22 |
def generate_email_from_groq(bio, company_name, role):
|
23 |
-
url = "https://api.groq.cloud/generate" #
|
24 |
headers = {
|
25 |
-
"Authorization": f"Bearer {groq_api_key}",
|
26 |
"Content-Type": "application/json",
|
27 |
}
|
28 |
prompt = f"Write a professional email applying for a {role} position at {company_name}. Use this bio: {bio}. The email should include an introduction, relevant experience, skills, and a closing."
|
|
|
29 |
data = {
|
30 |
-
"model": "groq-model", # Adjust
|
31 |
"prompt": prompt,
|
32 |
"max_tokens": 300
|
33 |
}
|
@@ -37,6 +38,8 @@ def generate_email_from_groq(bio, company_name, role):
|
|
37 |
if response.status_code == 200:
|
38 |
return response.json().get("choices")[0].get("text").strip()
|
39 |
else:
|
|
|
|
|
40 |
return "Error generating email. Please check your API key or try again later."
|
41 |
|
42 |
# Grammar and Tone Checker Function
|
|
|
5 |
import os
|
6 |
from datetime import datetime # Import datetime for date validation
|
7 |
|
8 |
+
# Load Groq Cloud API key securely from environment variables
|
9 |
groq_api_key = os.getenv("GROQ_CLOUD_API_KEY")
|
10 |
|
11 |
# Scraping function to fetch user public data (for demo purposes, we will simulate this)
|
|
|
20 |
|
21 |
# Helper function to call Groq Cloud LLM API to generate email
|
22 |
def generate_email_from_groq(bio, company_name, role):
|
23 |
+
url = "https://api.groq.cloud/generate" # Replace with the correct Groq Cloud API URL
|
24 |
headers = {
|
25 |
+
"Authorization": f"Bearer {groq_api_key}", # Use the API key securely from environment
|
26 |
"Content-Type": "application/json",
|
27 |
}
|
28 |
prompt = f"Write a professional email applying for a {role} position at {company_name}. Use this bio: {bio}. The email should include an introduction, relevant experience, skills, and a closing."
|
29 |
+
|
30 |
data = {
|
31 |
+
"model": "groq-model", # Adjust model name based on Groq documentation
|
32 |
"prompt": prompt,
|
33 |
"max_tokens": 300
|
34 |
}
|
|
|
38 |
if response.status_code == 200:
|
39 |
return response.json().get("choices")[0].get("text").strip()
|
40 |
else:
|
41 |
+
# Print or log the error for debugging
|
42 |
+
print(f"Error: {response.status_code}, {response.text}")
|
43 |
return "Error generating email. Please check your API key or try again later."
|
44 |
|
45 |
# Grammar and Tone Checker Function
|