mon2hf's picture
Upload app.py with huggingface_hub
5e38557 verified
from sentence_transformers import SentenceTransformer, util
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import uvicorn
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
model = SentenceTransformer("mon2hf/devops-job-matcher")
class MatchRequest(BaseModel):
job_description: str
profile_text: str
@app.get("/")
def root():
return {"status": "running", "model": "devops-job-matcher"}
@app.post("/match")
def match_job(req: MatchRequest):
job_emb = model.encode(req.job_description, convert_to_tensor=True)
prof_emb = model.encode(req.profile_text, convert_to_tensor=True)
score = float(util.cos_sim(job_emb, prof_emb)[0][0])
conf = round(score * 100, 1)
return {
"match_score": conf,
"apply": conf >= 70,
"label": "Strong match" if conf >= 80 else "Good match" if conf >= 70 else "Weak match"
}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=7860)