Spaces:
Running
Running
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)}" | |