Spaces:
Running
Running
File size: 585 Bytes
bb4e28f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from config.env import GROQ_API_KEY, GROQ_API_URL
import httpx
def call_groq_mistral(prompt: str) -> str:
headers = {"Authorization": f"Bearer {GROQ_API_KEY}"}
body = {
"model": "llama-3.1-8b-instant",
"messages": [{"role": "user", "content": prompt}],
"temperature": 0.7
}
try:
response = httpx.post(GROQ_API_URL, json=body, headers=headers, timeout=10)
response.raise_for_status()
return response.json()["choices"][0]["message"]["content"]
except Exception as e:
return f"❌ Error calling Groq: {str(e)}"
|