File size: 681 Bytes
84bc138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# groq_api.py
import os
import openai

# Set your Groq API key
openai.api_key = os.getenv("GROQ_API_KEY")
openai.api_base = "https://api.groq.com/openai/v1"

MODEL_NAME = "mixtral-8x7b-32768"  # You can change to another Groq-supported model

def get_summary(jd_text, matched_cvs):
    joined_cvs = "\n\n".join(matched_cvs)
    prompt = f"""
Given the following job description:

{jd_text}

And these CVs:

{joined_cvs}

Summarize which candidates best match the job description and why:
"""

    response = openai.ChatCompletion.create(
        model=MODEL_NAME,
        messages=[{"role": "user", "content": prompt}]
    )

    return response.choices[0].message.content.strip()