Spaces:
Sleeping
Sleeping
Download utils.py from aysan98/empathy-map-interview: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/spaces/aysan98/empathy-map-interview/resolve/main/utils.py
- Command line
-
hf download hf://spaces/aysan98/empathy-map-interview/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/aysan98/empathy-map-interview/resolve/main/utils.py
759 Bytes
| import requests | |
| class GroqClient: | |
| def __init__(self, api_key): | |
| self.api_key = api_key | |
| self.base_url = "https://api.groq.com/openai/v1/chat/completions" | |
| def chat_completion(self, messages, model="llama-3.3-70b-versatile", temperature=0.7, max_tokens=2048): | |
| headers = { | |
| "Authorization": f"Bearer {self.api_key}", | |
| "Content-Type": "application/json" | |
| } | |
| payload = { | |
| "model": model, | |
| "messages": messages, | |
| "temperature": temperature, | |
| "max_tokens": max_tokens | |
| } | |
| response = requests.post(self.base_url, headers=headers, json=payload) | |
| response.raise_for_status() | |
| return response.json() | |