|
|
|
""" |
|
Test script for local API endpoint |
|
""" |
|
import requests |
|
import json |
|
|
|
|
|
API_URL = "http://localhost:8000/v1/chat/completions" |
|
|
|
|
|
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}") |
|
|