Spaces:
Sleeping
Sleeping
File size: 1,228 Bytes
8b6aa48 9e9d5ee 8b6aa48 23a9800 8b6aa48 9e9d5ee 9d8b461 9e9d5ee 8b6aa48 9e9d5ee 8b6aa48 9e9d5ee 8b6aa48 9e9d5ee 8b6aa48 9e9d5ee 8b6aa48 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import pandas as pd
import gradio as gr
from retriever import get_relevant_passages
from reranker import rerank
# Load and clean CSV
df = pd.read_csv("assesments.csv")
def clean_df(df):
df = df.copy()
df["url"] = "https://www.shl.com" + df.iloc[:, 1].astype(str)
df["remote_support"] = df.iloc[:, 2].map(lambda x: "Yes" if x == "T" else "No")
df["adaptive_support"] = df.iloc[:, 3].map(lambda x: "Yes" if x == "T" else "No")
df["test_type"] = df.iloc[:, 4].astype(str).str.split("\\n")
df["description"] = df.iloc[:, 5]
df["duration"] = df.iloc[:, 8].astype(str).str.extract(r'(\d+)').astype(float)
return df[["url", "adaptive_support", "remote_support", "description", "duration", "test_type"]]
df_clean = clean_df(df)
def recommend(query):
top_k_df = get_relevant_passages(query, df_clean, top_k=20)
candidates = top_k_df.to_dict(orient="records")
return rerank(query, candidates)
iface = gr.Interface(
fn=recommend,
inputs=gr.Textbox(label="Enter Job Description", lines=4),
outputs="json",
title="SHL Assessment Recommender",
description="Paste a job description to get the most relevant SHL assessments."
)
if __name__ == "__main__":
iface.launch()
|