#!/usr/bin/env python3 """ Test script for local API endpoint """ import requests import json # Local API endpoint API_URL = "http://localhost:8000/v1/chat/completions" # Test payload with the correct model name payload = { "model": "unsloth/DeepSeek-R1-0528-Qwen3-8B-GGUF", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello, what can you do?"} ], "max_tokens": 64, "temperature": 0.7 } print("๐Ÿงช Testing Local API...") print(f"๐Ÿ“ก URL: {API_URL}") print(f"๐Ÿ“ฆ Payload: {json.dumps(payload, indent=2)}") print("-" * 50) try: response = requests.post(API_URL, json=payload, timeout=30) print(f"โœ… Status: {response.status_code}") if response.status_code == 200: result = response.json() print(f"๐Ÿค– Response: {json.dumps(result, indent=2)}") if 'choices' in result and len(result['choices']) > 0: print(f"๐Ÿ’ฌ AI Message: {result['choices'][0]['message']['content']}") else: print(f"โŒ Error: {response.text}") except requests.exceptions.ConnectionError: print("โŒ Connection failed - make sure the server is running locally") except requests.exceptions.Timeout: print("โฐ Request timed out") except Exception as e: print(f"โŒ Error: {e}")