aazankhanYousafzai commited on
Commit
dcc2619
·
verified ·
1 Parent(s): 34552ed

Create llm.py

Browse files
Files changed (1) hide show
  1. llm.py +20 -0
llm.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # llm.py
2
+ import os
3
+ from groq import Groq
4
+
5
+ groq_api_key = os.environ.get("GROQ_API_KEY")
6
+
7
+ if groq_api_key is None:
8
+ raise RuntimeError("GROQ_API_KEY not found in environment variables")
9
+
10
+ client = Groq(api_key=groq_api_key)
11
+
12
+ def ask_llm(prompt: str) -> str:
13
+ response = client.chat.completions.create(
14
+ model="llama-3.3-70b-versatile",
15
+ messages=[
16
+ {"role": "system", "content": "You are a helpful voice assistant."},
17
+ {"role": "user", "content": prompt},
18
+ ],
19
+ )
20
+ return response.choices[0].message.content