File size: 559 Bytes
dcc2619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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