saherPervaiz commited on
Commit
84bc138
·
verified ·
1 Parent(s): ba68800

Create groq_api.py

Browse files
Files changed (1) hide show
  1. groq_api.py +30 -0
groq_api.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # groq_api.py
2
+ import os
3
+ import openai
4
+
5
+ # Set your Groq API key
6
+ openai.api_key = os.getenv("GROQ_API_KEY")
7
+ openai.api_base = "https://api.groq.com/openai/v1"
8
+
9
+ MODEL_NAME = "mixtral-8x7b-32768" # You can change to another Groq-supported model
10
+
11
+ def get_summary(jd_text, matched_cvs):
12
+ joined_cvs = "\n\n".join(matched_cvs)
13
+ prompt = f"""
14
+ Given the following job description:
15
+
16
+ {jd_text}
17
+
18
+ And these CVs:
19
+
20
+ {joined_cvs}
21
+
22
+ Summarize which candidates best match the job description and why:
23
+ """
24
+
25
+ response = openai.ChatCompletion.create(
26
+ model=MODEL_NAME,
27
+ messages=[{"role": "user", "content": prompt}]
28
+ )
29
+
30
+ return response.choices[0].message.content.strip()