File size: 1,108 Bytes
32ea7ac
 
5e38557
 
 
 
 
 
 
 
 
 
 
 
 
32ea7ac
 
 
5e38557
 
 
 
 
 
 
 
 
 
 
 
32ea7ac
 
 
 
5e38557
 
32ea7ac
 
5e38557
 
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
37
38
39
40
41

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)