saherPervaiz commited on
Commit
fb85604
·
verified ·
1 Parent(s): 4d83474

Update groq_api.py

Browse files
Files changed (1) hide show
  1. groq_api.py +15 -7
groq_api.py CHANGED
@@ -3,15 +3,21 @@
3
  import os
4
  import requests
5
 
6
- GROQ_API_KEY = "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"
7
 
8
  def summarize_match(job_description, cv_names, cv_snippets):
9
  if not GROQ_API_KEY:
10
  return "❌ GROQ_API_KEY not set."
11
 
12
- cv_info = "\n\n".join([f"{cv_names[i]}:\n{cv_snippets[i]}" for i in range(len(cv_names))])
13
-
14
- prompt = f"""
 
 
 
 
 
 
15
  You are an AI recruiter assistant.
16
 
17
  A company has the following job description:
@@ -19,13 +25,15 @@ A company has the following job description:
19
  {job_description}
20
  ---
21
 
22
- Here are the top 3 candidate CVs (partial text):
23
  {cv_info}
24
 
25
- Based on the job description and CV content, summarize why these candidates are relevant.
26
  """
27
 
28
- try:
 
 
29
  response = requests.post(
30
  url="https://api.groq.com/openai/v1/chat/completions",
31
  headers={
 
3
  import os
4
  import requests
5
 
6
+ GROQ_API_KEY ="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"
7
 
8
  def summarize_match(job_description, cv_names, cv_snippets):
9
  if not GROQ_API_KEY:
10
  return "❌ GROQ_API_KEY not set."
11
 
12
+ try:
13
+ # Safeguard input
14
+ job_description = job_description.strip() or "[No description]"
15
+ cv_info = "\n\n".join([
16
+ f"{cv_names[i]}:\n{cv_snippets[i].strip() or '[No content]'}"
17
+ for i in range(len(cv_names))
18
+ ])
19
+
20
+ prompt = f"""
21
  You are an AI recruiter assistant.
22
 
23
  A company has the following job description:
 
25
  {job_description}
26
  ---
27
 
28
+ Here are the top 3 candidate CVs (partial content):
29
  {cv_info}
30
 
31
+ Please summarize why these candidates are relevant for the job.
32
  """
33
 
34
+ print("=== Prompt Sent to Groq ===")
35
+ print(prompt[:1500]) # show only first 1500 chars
36
+
37
  response = requests.post(
38
  url="https://api.groq.com/openai/v1/chat/completions",
39
  headers={