-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_chutes.py
More file actions
73 lines (62 loc) · 2.03 KB
/
Copy pathtest_chutes.py
File metadata and controls
73 lines (62 loc) · 2.03 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import json
import os
import requests
from dotenv import load_dotenv
def main() -> int:
load_dotenv()
chutes_api_token = os.environ.get("CHUTES_API_TOKEN")
if not chutes_api_token:
print("Error: CHUTES_API_TOKEN not found in environment variables")
return 1
print("Testing direct connection to Chutes API...")
response = requests.post(
"https://llm.chutes.ai/v1/completions",
headers={
"Authorization": f"Bearer {chutes_api_token}",
"Content-Type": "application/json",
},
json={
"model": "deepseek-ai/DeepSeek-V3",
"prompt": "My favourite type of cat",
"stream": False,
"max_tokens": 100,
"temperature": 0.7,
},
)
print(f"Status code: {response.status_code}")
if response.status_code == 200:
print("Direct connection successful!")
print("Response:")
print(json.dumps(response.json(), indent=2))
else:
print("Direct connection failed!")
print("Response:")
print(response.text)
print("\nTesting connection through the proxy...")
proxy_url = "http://localhost:1400"
response = requests.post(
f"{proxy_url}/chutes/v1/completions",
headers={
"Authorization": f"Bearer {os.environ.get('ADMIN_API_KEY')}",
"Content-Type": "application/json",
},
json={
"model": "deepseek-ai/DeepSeek-V3",
"prompt": "My favourite type of cat",
"stream": False,
"max_tokens": 100,
"temperature": 0.7,
},
)
print(f"Status code: {response.status_code}")
if response.status_code == 200:
print("Proxy connection successful!")
print("Response:")
print(json.dumps(response.json(), indent=2))
else:
print("Proxy connection failed!")
print("Response:")
print(response.text)
return 0 if response.status_code == 200 else 1
if __name__ == "__main__":
raise SystemExit(main())