Spaces:
Sleeping
Sleeping
Update utils/suggestions.py
Browse files- utils/suggestions.py +10 -6
utils/suggestions.py
CHANGED
|
@@ -2,7 +2,7 @@ import requests
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
HF_API_KEY = os.getenv("HF_API_KEY")
|
| 5 |
-
HF_MODEL = "
|
| 6 |
HF_API_URL = f"https://api-inference.huggingface.co/models/{HF_MODEL}"
|
| 7 |
|
| 8 |
HEADERS = {
|
|
@@ -10,6 +10,7 @@ HEADERS = {
|
|
| 10 |
"Content-Type": "application/json"
|
| 11 |
}
|
| 12 |
|
|
|
|
| 13 |
def call_llm(prompt: str) -> str:
|
| 14 |
response = requests.post(
|
| 15 |
HF_API_URL,
|
|
@@ -21,24 +22,27 @@ def call_llm(prompt: str) -> str:
|
|
| 21 |
|
| 22 |
try:
|
| 23 |
return response.json()[0]["generated_text"]
|
| 24 |
-
except:
|
| 25 |
raise Exception(f"Error parsing Hugging Face response: {response.text}")
|
| 26 |
|
| 27 |
|
| 28 |
def get_certification_suggestions(text: str) -> str:
|
| 29 |
-
prompt = f"Suggest 5
|
| 30 |
return call_llm(prompt)
|
| 31 |
|
|
|
|
| 32 |
def get_higher_education_suggestions(text: str) -> str:
|
| 33 |
-
prompt = f"Suggest
|
| 34 |
return call_llm(prompt)
|
| 35 |
|
|
|
|
| 36 |
def get_visa_recommendations(text: str) -> str:
|
| 37 |
-
prompt = f"Suggest visa
|
| 38 |
return call_llm(prompt)
|
| 39 |
|
|
|
|
| 40 |
def get_career_advice(text: str) -> str:
|
| 41 |
-
prompt = f"Give career advice
|
| 42 |
return call_llm(prompt)
|
| 43 |
|
| 44 |
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
HF_API_KEY = os.getenv("HF_API_KEY")
|
| 5 |
+
HF_MODEL = "google/flan-t5-small"
|
| 6 |
HF_API_URL = f"https://api-inference.huggingface.co/models/{HF_MODEL}"
|
| 7 |
|
| 8 |
HEADERS = {
|
|
|
|
| 10 |
"Content-Type": "application/json"
|
| 11 |
}
|
| 12 |
|
| 13 |
+
|
| 14 |
def call_llm(prompt: str) -> str:
|
| 15 |
response = requests.post(
|
| 16 |
HF_API_URL,
|
|
|
|
| 22 |
|
| 23 |
try:
|
| 24 |
return response.json()[0]["generated_text"]
|
| 25 |
+
except Exception as e:
|
| 26 |
raise Exception(f"Error parsing Hugging Face response: {response.text}")
|
| 27 |
|
| 28 |
|
| 29 |
def get_certification_suggestions(text: str) -> str:
|
| 30 |
+
prompt = f"Suggest 5 certifications for this resume: {text}"
|
| 31 |
return call_llm(prompt)
|
| 32 |
|
| 33 |
+
|
| 34 |
def get_higher_education_suggestions(text: str) -> str:
|
| 35 |
+
prompt = f"Suggest higher education programs for this resume: {text}"
|
| 36 |
return call_llm(prompt)
|
| 37 |
|
| 38 |
+
|
| 39 |
def get_visa_recommendations(text: str) -> str:
|
| 40 |
+
prompt = f"Suggest visa opportunities in top countries based on this resume: {text}"
|
| 41 |
return call_llm(prompt)
|
| 42 |
|
| 43 |
+
|
| 44 |
def get_career_advice(text: str) -> str:
|
| 45 |
+
prompt = f"Give career counseling advice based on this resume: {text}"
|
| 46 |
return call_llm(prompt)
|
| 47 |
|
| 48 |
|