saifeddinemk commited on
Commit
e079d59
·
1 Parent(s): 9208e17

Fixed app v2

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -1,11 +1,12 @@
1
  import gradio as gr
2
  from llama_cpp import Llama
 
3
 
4
- # Load the SecurityLLM model
5
  try:
6
  llm = Llama.from_pretrained(
7
- repo_id="QuantFactory/SecurityLLM-GGUF",
8
- filename="SecurityLLM.Q5_K_M.gguf", # Ensure the file path is correct
9
  )
10
  except Exception as e:
11
  raise RuntimeError(f"Failed to load model: {e}")
@@ -33,25 +34,34 @@ def match_cv_to_jobs(cv_text, job_descriptions):
33
  ]
34
  )
35
 
36
- # Extract and store the analysis text
37
  analysis_text = response["choices"][0]["message"]["content"]
38
- results.append({
39
- "Job Description": description,
40
- "Analysis": analysis_text
41
- })
 
 
 
 
 
 
42
 
43
  return results
44
 
45
  # Gradio interface
46
  with gr.Blocks() as demo:
47
- gr.Markdown("# CV to Job Description Matcher")
48
 
 
49
  cv_text = gr.Textbox(label="CV Text", placeholder="Enter the CV text here", lines=10)
50
  job_descriptions = gr.Textbox(label="Job Descriptions (one per line)", placeholder="Enter each job description on a new line", lines=5)
51
- match_button = gr.Button("Match CV to Job Descriptions")
52
 
 
 
53
  output = gr.JSON(label="Match Results")
54
 
 
55
  match_button.click(fn=match_cv_to_jobs, inputs=[cv_text, job_descriptions], outputs=output)
56
 
57
  demo.launch()
 
1
  import gradio as gr
2
  from llama_cpp import Llama
3
+ import json
4
 
5
+ # Load the Llama model
6
  try:
7
  llm = Llama.from_pretrained(
8
+ repo_id="HuggingFaceTB/SmolLM2-360M-Instruct-GGUF",
9
+ filename="smollm2-360m-instruct-q8_0.gguf" # Replace with the correct path to your GGUF file
10
  )
11
  except Exception as e:
12
  raise RuntimeError(f"Failed to load model: {e}")
 
34
  ]
35
  )
36
 
37
+ # Extract the analysis text
38
  analysis_text = response["choices"][0]["message"]["content"]
39
+
40
+ # Attempt to parse as JSON; if not JSON, use the raw text
41
+ try:
42
+ response_data = json.loads(analysis_text)
43
+ results.append(response_data)
44
+ except json.JSONDecodeError:
45
+ results.append({
46
+ "Job Description": description,
47
+ "Analysis": analysis_text # Use raw response if JSON parsing fails
48
+ })
49
 
50
  return results
51
 
52
  # Gradio interface
53
  with gr.Blocks() as demo:
54
+ gr.Markdown("# CV and Job Description Matcher")
55
 
56
+ # Input fields for CV and job descriptions
57
  cv_text = gr.Textbox(label="CV Text", placeholder="Enter the CV text here", lines=10)
58
  job_descriptions = gr.Textbox(label="Job Descriptions (one per line)", placeholder="Enter each job description on a new line", lines=5)
 
59
 
60
+ # Button and output area
61
+ match_button = gr.Button("Match CV to Job Descriptions")
62
  output = gr.JSON(label="Match Results")
63
 
64
+ # Set button click to run the function
65
  match_button.click(fn=match_cv_to_jobs, inputs=[cv_text, job_descriptions], outputs=output)
66
 
67
  demo.launch()