Spaces:
Build error
Build error
| import axios from "axios"; | |
| const API_KEY = process.env.GROQ_API_KEY; | |
| export async function askGroq(question) { | |
| try { | |
| const res = await axios.post( | |
| "https://api.groq.com/openai/v1/chat/completions", | |
| { | |
| model: "llama-3.3-70b-versatile", | |
| messages: [{ role: "user", content: question }], | |
| }, | |
| { | |
| headers: { | |
| "Content-Type": "application/json", | |
| Authorization: `Bearer ${API_KEY}`, | |
| }, | |
| } | |
| ); | |
| return res.data.choices[0].message.content; | |
| } catch (err) { | |
| console.error("Groq error:", err); | |
| return "Sorry, I couldn't reach the AI service."; | |
| } | |
| } | |