45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
# test_llm_endpoint.py
|
|
import requests
|
|
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
base_url = os.getenv("LLM_API_URL", "http://api.chat.pathcore.org")
|
|
|
|
# Test different possible endpoints
|
|
endpoints = [
|
|
f"{base_url}/v1/chat/completions",
|
|
f"{base_url}/chat/completions",
|
|
f"{base_url}/completions",
|
|
f"{base_url}/v1/completions",
|
|
f"{base_url}/api/v1/chat/completions",
|
|
]
|
|
|
|
print(f"Testing LLM API endpoints...\n")
|
|
|
|
for endpoint in endpoints:
|
|
print(f"Testing: {endpoint}")
|
|
try:
|
|
# Try a simple GET request first
|
|
resp = requests.get(endpoint, timeout=5, verify=False)
|
|
print(f" GET response: {resp.status_code}")
|
|
|
|
# Try POST with minimal data
|
|
resp = requests.post(
|
|
endpoint,
|
|
json={
|
|
"model": "default",
|
|
"messages": [{"role": "user", "content": "test"}]
|
|
},
|
|
timeout=5,
|
|
verify=False
|
|
)
|
|
print(f" POST response: {resp.status_code}")
|
|
if resp.status_code == 200:
|
|
print(f" ✓ SUCCESS! This endpoint works!")
|
|
print(f" Response: {resp.json()}")
|
|
break
|
|
except Exception as e:
|
|
print(f" Error: {e}")
|
|
print() |