File size: 1,337 Bytes
3239c69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/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}")
|