Spaces:
Runtime error
Runtime error
fix
Browse files- ai_suggestions.py +20 -5
ai_suggestions.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
HF_API_URL = "https://api-inference.huggingface.co/models/
|
| 5 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 6 |
|
| 7 |
HEADERS = {
|
|
@@ -45,12 +45,27 @@ def generate_suggestions(resume_text, jd_text, ats_result):
|
|
| 45 |
payload = {
|
| 46 |
"inputs": build_prompt(resume_text, jd_text, ats_result),
|
| 47 |
"parameters": {
|
| 48 |
-
"max_new_tokens":
|
| 49 |
"temperature": 0.4,
|
| 50 |
"return_full_text": False
|
| 51 |
}
|
| 52 |
}
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
HF_API_URL = "https://api-inference.huggingface.co/models/google/gemma-2b-it"
|
| 5 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 6 |
|
| 7 |
HEADERS = {
|
|
|
|
| 45 |
payload = {
|
| 46 |
"inputs": build_prompt(resume_text, jd_text, ats_result),
|
| 47 |
"parameters": {
|
| 48 |
+
"max_new_tokens": 300,
|
| 49 |
"temperature": 0.4,
|
| 50 |
"return_full_text": False
|
| 51 |
}
|
| 52 |
}
|
| 53 |
|
| 54 |
+
try:
|
| 55 |
+
response = requests.post(
|
| 56 |
+
HF_API_URL,
|
| 57 |
+
headers=HEADERS,
|
| 58 |
+
json=payload,
|
| 59 |
+
timeout=60
|
| 60 |
+
)
|
| 61 |
+
response.raise_for_status()
|
| 62 |
+
return response.json()[0]["generated_text"]
|
| 63 |
+
|
| 64 |
+
except Exception as e:
|
| 65 |
+
return (
|
| 66 |
+
"AI suggestions are temporarily unavailable.\n"
|
| 67 |
+
"General advice:\n"
|
| 68 |
+
"- Add measurable results (accuracy, scale, impact)\n"
|
| 69 |
+
"- Use strong action verbs\n"
|
| 70 |
+
"- Align skills with job description\n"
|
| 71 |
+
)
|