Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,19 @@
|
|
1 |
-
import os
|
2 |
-
import openai
|
3 |
import gradio as gr
|
4 |
-
from keybert
|
5 |
-
from
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
client = openai
|
11 |
-
|
12 |
-
# π§ Initialize KeyLLM
|
13 |
-
llm = KeyBERTOpenAI(client)
|
14 |
-
kw_model = KeyLLM(llm)
|
15 |
|
|
|
16 |
def extract_keywords(job_desc, resume_text, analyze_with_jd):
|
17 |
-
|
18 |
-
|
19 |
-
return "Please paste your resume text."
|
20 |
-
|
21 |
-
text = job_desc + "\n\n" + resume_text if analyze_with_jd and job_desc else resume_text
|
22 |
-
keywords = kw_model.extract_keywords([text], check_vocab=True)
|
23 |
-
return ", ".join(keywords[0]) if keywords else "No keywords found."
|
24 |
-
except Exception as e:
|
25 |
-
return f"β Error: {str(e)}"
|
26 |
|
|
|
|
|
|
|
27 |
|
28 |
# ποΈ Gradio UI
|
29 |
with gr.Blocks() as demo:
|
@@ -35,8 +25,7 @@ with gr.Blocks() as demo:
|
|
35 |
with gr.Column():
|
36 |
output_keywords = gr.Textbox(label="Extracted Keywords", lines=12)
|
37 |
|
38 |
-
# Trigger keyword extraction when any input changes
|
39 |
-
job_desc.change(fn=extract_keywords, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_keywords)
|
40 |
resume_text.change(fn=extract_keywords, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_keywords)
|
|
|
41 |
|
42 |
demo.launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from keybert import KeyBERT
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
|
5 |
+
# β
Load Hugging Face model (no API key needed)
|
6 |
+
model = SentenceTransformer('all-MiniLM-L6-v2')
|
7 |
+
kw_model = KeyBERT(model)
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# π Keyword extraction function
|
10 |
def extract_keywords(job_desc, resume_text, analyze_with_jd):
|
11 |
+
if not resume_text.strip():
|
12 |
+
return "Please paste your resume."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
text = job_desc + "\n\n" + resume_text if analyze_with_jd and job_desc else resume_text
|
15 |
+
keywords = kw_model.extract_keywords(text, top_n=10, stop_words='english')
|
16 |
+
return ", ".join([kw for kw, _ in keywords]) if keywords else "No keywords found."
|
17 |
|
18 |
# ποΈ Gradio UI
|
19 |
with gr.Blocks() as demo:
|
|
|
25 |
with gr.Column():
|
26 |
output_keywords = gr.Textbox(label="Extracted Keywords", lines=12)
|
27 |
|
|
|
|
|
28 |
resume_text.change(fn=extract_keywords, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_keywords)
|
29 |
+
job_desc.change(fn=extract_keywords, inputs=[job_desc, resume_text, analyze_checkbox], outputs=output_keywords)
|
30 |
|
31 |
demo.launch()
|