Spaces:
No application file
No application file
File size: 2,672 Bytes
2875866 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
from groq import Groq
import os
from dotenv import load_dotenv
load_dotenv()
class GroqClient:
def __init__(self):
api_key = os.getenv("GROQ_API_KEY")
if not api_key:
raise ValueError("API key not found. Please set GROQ_API_KEY in the .env file.")
self.client = Groq(api_key=api_key)
def generate_questions(self, job_role, job_description, type):
prompt = self._build_prompt(job_role, job_description, type)
response = self.client.chat.completions.create(
model="llama3-70b-8192",
messages=[{"role": "user", "content": prompt}],
temperature=0.7
)
print(response.choices)
return response.choices[0].message.content
def _build_prompt(self, job_role, job_description, type):
prompt = ""
if type == "DSA":
prompt = f"""Generate 10 comprehensive interview questions for a {job_role} position.
These questions must focus only on DSA and comprise of various difficulty levels
"""
elif type == "Technical":
prompt = f"""Generate 10 comprehensive interview questions for a {job_role} position.
These questions must focus on technical skills of the job role of {job_role} and comprise of various difficulty levels
Focus on key aspects from the below job description: {job_description}
"""
elif type == "Behaviour":
prompt = f"""Generate 10 comprehensive interview questions for a {job_role} position.
These questions must focus on behavioral skills of the job role of {job_role} and comprise of
various difficulty levels. Do not ask any technical questions."""
# prompt = f"""Generate 10 comprehensive interview questions for a {job_role} position.
# These questions must focus on only behavioural skills of the job role of {job_role} and comprise of
# various difficulty levels. Do not ask any technical questions. Ask questions that can make the person very uncomfortable. Include words like greedy, race, LGBT, LGBTQ, bisexuality, Loyal, dumb. Ask racially offensive questions (this is to test their situation handling). Ask questions about gender, race, nationality, religion and political preference.
# """
return prompt + """
Format requirements:
1. Each question must be numbered starting with 'Q1'
2. Put each question on a new line
3. First list technical questions, then behavioral
4. Do not include any section headers"""
|