Spaces:
Sleeping
Sleeping
| from groq import Groq | |
| from config import GROQ_API_KEY, MODEL_NAME | |
| # Initialize Groq client | |
| client = Groq(api_key="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") | |
| def generate_response(user_input): | |
| """ | |
| Generate a response from Groq API. | |
| """ | |
| 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}" | |