Spaces:
Sleeping
Sleeping
| # groq_handler.py | |
| import os | |
| from groq import Groq | |
| from dotenv import load_dotenv | |
| # Load environment variables from .env | |
| load_dotenv() | |
| # Initialize Groq client | |
| client = Groq(api_key=os.getenv("GROQ_API_KEY")) | |
| # Function to call Groq's chatbot | |
| def ask_groq(prompt, model="llama3-70b-8192"): | |
| chat_completion = client.chat.completions.create( | |
| messages=[{"role": "user", "content": prompt}], | |
| model=model, | |
| ) | |
| return chat_completion.choices[0].message.content | |