Spaces:
Sleeping
Sleeping
Update utils/suggestions.py
Browse files- utils/suggestions.py +24 -53
utils/suggestions.py
CHANGED
|
@@ -1,60 +1,31 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
model_name = "microsoft/phi-2"
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 8 |
-
model_name,
|
| 9 |
-
torch_dtype=torch.float32
|
| 10 |
-
)
|
| 11 |
-
model.eval()
|
| 12 |
|
| 13 |
-
def
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
outputs = model.generate(
|
| 17 |
-
inputs["input_ids"],
|
| 18 |
-
max_new_tokens=250,
|
| 19 |
-
do_sample=True,
|
| 20 |
-
temperature=0.7,
|
| 21 |
-
top_k=50
|
| 22 |
-
)
|
| 23 |
-
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 24 |
|
| 25 |
-
def
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
""
|
| 33 |
-
|
| 34 |
-
return response.strip()
|
| 35 |
|
| 36 |
-
def
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
response = call_llm(prompt)
|
| 43 |
-
return response.strip()
|
| 44 |
-
|
| 45 |
-
def get_visa_recommendations(cv_text):
|
| 46 |
-
prompt = f"""You are a global career visa advisor. Based on the following CV text, suggest 3 countries where the candidate has a high chance of qualifying for a work visa. Mention the type of visa, eligibility reasons, and links if possible.
|
| 47 |
-
|
| 48 |
-
CV:
|
| 49 |
-
{cv_text}
|
| 50 |
-
"""
|
| 51 |
-
response = call_llm(prompt)
|
| 52 |
-
return response.strip()
|
| 53 |
-
|
| 54 |
-
def get_career_advice(cv_text):
|
| 55 |
-
prompt = f"""You are a professional career counselor. Analyze the following CV text and give personalized career advice. Mention areas of improvement, potential career paths, and tips for international job hunting.
|
| 56 |
-
|
| 57 |
-
CV:
|
| 58 |
-
{cv_text}
|
| 59 |
-
"""
|
| 60 |
-
return call_llm(prompt).strip()
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
+
BASE_DIR = os.path.join(os.path.dirname(__file__), "..", "csvs")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def load_csv(filename):
|
| 7 |
+
path = os.path.join(BASE_DIR, filename)
|
| 8 |
+
return pd.read_csv(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
def match_field(field, df):
|
| 11 |
+
field = field.strip().lower()
|
| 12 |
+
match = df[df['field'].str.lower().str.contains(field)]
|
| 13 |
+
if not match.empty:
|
| 14 |
+
return match['suggestion'].tolist()
|
| 15 |
+
return ["No specific suggestions found for this field."]
|
| 16 |
|
| 17 |
+
def get_certification_suggestions(field):
|
| 18 |
+
df = load_csv("certifications.csv")
|
| 19 |
+
return match_field(field, df)
|
| 20 |
|
| 21 |
+
def get_higher_education_suggestions(field):
|
| 22 |
+
df = load_csv("education.csv")
|
| 23 |
+
return match_field(field, df)
|
|
|
|
| 24 |
|
| 25 |
+
def get_visa_recommendations(field):
|
| 26 |
+
df = load_csv("visa.csv")
|
| 27 |
+
return match_field(field, df)
|
| 28 |
|
| 29 |
+
def get_career_advice(field):
|
| 30 |
+
df = load_csv("career_advice.csv")
|
| 31 |
+
return match_field(field, df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|