| import requests | |
| # Hugging Face Space API endpoint | |
| API_URL = "https://cong182-firstai.hf.space/v1/chat/completions" | |
| # Example payload for OpenAI-compatible chat completion | |
| payload = { | |
| "model": "unsloth/DeepSeek-R1-0528-Qwen3-8B-GGUF", | |
| "messages": [ | |
| {"role": "system", "content": "You are a helpful assistant."}, | |
| {"role": "user", "content": "Hello, who won the world cup in 2018?"} | |
| ], | |
| "max_tokens": 64, | |
| "temperature": 0.7 | |
| } | |
| try: | |
| response = requests.post(API_URL, json=payload, timeout=30) | |
| response.raise_for_status() | |
| print("Status:", response.status_code) | |
| print("Response:", response.json()) | |
| except Exception as e: | |
| print("Error during API call:", e) | |