Chatbot1 / utils.py
saherPervaiz's picture
Update utils.py
c60864a verified
raw
history blame contribute delete
435 Bytes
from groq import Groq
from config import GROQ_API_KEY, MODEL_NAME
# Initialize Groq client
client = Groq(api_key=GROQ_API_KEY)
def generate_response(user_input):
try:
response = client.chat.completions.create(
messages=[{"role": "user", "content": user_input}],
model=MODEL_NAME,
)
return response.choices[0].message.content
except Exception as e:
return f"Error: {e}"