Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"""You are an expert career coach. Write a personalized cover letter for the following resume and job description.
|
| 12 |
+
|
| 13 |
+
Resume:
|
| 14 |
+
{resume}
|
| 15 |
+
|
| 16 |
+
Job Description:
|
| 17 |
+
{job_desc}
|
| 18 |
+
|
| 19 |
+
The letter should be professional, concise, and ATS-friendly.
|
| 20 |
+
"""
|
| 21 |
+
data = {
|
| 22 |
+
"model": "meta-llama/llama-4-maverick:free",
|
| 23 |
+
"messages": [{"role": "user", "content": prompt}],
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
response = requests.post(API_URL, headers=HEADERS, json=data)
|
| 27 |
+
result = response.json()
|
| 28 |
+
return result['choices'][0]['message']['content']
|
| 29 |
+
|
| 30 |
+
gr.Interface(
|
| 31 |
+
fn=generate_cover_letter,
|
| 32 |
+
inputs=["textarea", "textarea"],
|
| 33 |
+
outputs="textbox",
|
| 34 |
+
title="AI Cover Letter Generator (MVP)",
|
| 35 |
+
description="Paste your resume and job description to generate a tailored cover letter."
|
| 36 |
+
).launch()
|