Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
API_URL = "https://openrouter.ai/api/v1/chat/completions"
|
| 5 |
-
HEADERS = {
|
| 6 |
-
"Authorization": "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", # Optional if using Maverick Free model
|
| 7 |
-
"Content-Type": "application/json"
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
def generate_cover_letter(resume, job_desc):
|
| 11 |
-
prompt = f"""
|
|
|
|
| 12 |
|
| 13 |
Resume:
|
| 14 |
{resume}
|
|
@@ -16,21 +11,34 @@ Resume:
|
|
| 16 |
Job Description:
|
| 17 |
{job_desc}
|
| 18 |
|
| 19 |
-
The letter should be
|
| 20 |
"""
|
| 21 |
-
data = {
|
| 22 |
-
"model": "meta-llama/llama-4-maverick:free",
|
| 23 |
-
"messages": [{"role": "user", "content": prompt}],
|
| 24 |
-
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
| 30 |
gr.Interface(
|
| 31 |
fn=generate_cover_letter,
|
| 32 |
-
inputs=[
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
def generate_cover_letter(resume, job_desc):
|
| 5 |
+
prompt = f"""
|
| 6 |
+
You are a career coach. Write a tailored, ATS-optimized, professional cover letter based on the resume and job description below.
|
| 7 |
|
| 8 |
Resume:
|
| 9 |
{resume}
|
|
|
|
| 11 |
Job Description:
|
| 12 |
{job_desc}
|
| 13 |
|
| 14 |
+
The letter should be concise, engaging, and show why the candidate is a good fit.
|
| 15 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# Send request to DeepSeek via PiAPI
|
| 18 |
+
response = requests.post(
|
| 19 |
+
"https://piapi.ai/api/deepseek",
|
| 20 |
+
headers={"Content-Type": "application/json"},
|
| 21 |
+
json={
|
| 22 |
+
"prompt": prompt,
|
| 23 |
+
"system": "You are a helpful assistant.",
|
| 24 |
+
"temperature": 0.8
|
| 25 |
+
}
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
data = response.json()
|
| 30 |
+
return data.get("response", "⚠️ No response received from DeepSeek.")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
return f"❌ Error: {str(e)}"
|
| 33 |
|
| 34 |
+
# Gradio UI
|
| 35 |
gr.Interface(
|
| 36 |
fn=generate_cover_letter,
|
| 37 |
+
inputs=[
|
| 38 |
+
gr.Textbox(label="Paste Your Resume", lines=12, placeholder="Paste your resume here..."),
|
| 39 |
+
gr.Textbox(label="Paste Job Description", lines=10, placeholder="Paste the job description here...")
|
| 40 |
+
],
|
| 41 |
+
outputs=gr.Textbox(label="Generated Cover Letter"),
|
| 42 |
+
title="AI Cover Letter Generator (DeepSeek LLM)",
|
| 43 |
+
description="Paste your resume and job description. Click 'Submit' to generate a personalized, professional cover letter using DeepSeek via PiAPI (no key needed)."
|
| 44 |
).launch()
|