| # llm.py | |
| import os | |
| from groq import Groq | |
| groq_api_key = os.environ.get("GROQ_API_KEY") | |
| if groq_api_key is None: | |
| raise RuntimeError("GROQ_API_KEY not found in environment variables") | |
| client = Groq(api_key=groq_api_key) | |
| def ask_llm(prompt: str) -> str: | |
| response = client.chat.completions.create( | |
| model="llama-3.3-70b-versatile", | |
| messages=[ | |
| {"role": "system", "content": "You are a helpful voice assistant."}, | |
| {"role": "user", "content": prompt}, | |
| ], | |
| ) | |
| return response.choices[0].message.content |