forked from ujaandas/gah2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_minimal_request.py
More file actions
62 lines (52 loc) · 1.7 KB
/
test_minimal_request.py
File metadata and controls
62 lines (52 loc) · 1.7 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
#!/usr/bin/env python3
"""
Test with minimal request matching curl exactly.
"""
import httpx
import os
from pathlib import Path
from dotenv import load_dotenv
# Load env vars
env_path = Path(__file__).parent / "backend" / ".env"
load_dotenv(env_path)
TEAM_ID = os.getenv("TEAM_ID")
API_TOKEN = os.getenv("API_TOKEN")
API_ENDPOINT = "https://ctwa92wg1b.execute-api.us-east-1.amazonaws.com/prod/invoke"
print("Testing minimal request (matching curl exactly)")
print("=" * 60)
headers = {
"Content-Type": "application/json",
"X-Team-ID": TEAM_ID,
"X-API-Token": API_TOKEN
}
# Test 1: With temperature and top_p
print("\nTest 1: With temperature and top_p")
payload1 = {
"team_id": TEAM_ID,
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
"messages": [{"role": "user", "content": "Say hi"}],
"max_tokens": 50,
"temperature": 0.7,
"top_p": 0.9
}
with httpx.Client(timeout=30) as client:
response = client.post(API_ENDPOINT, headers=headers, json=payload1)
print(f"Status: {response.status_code}")
if not response.is_success:
print(f"Error: {response.text}")
# Test 2: WITHOUT temperature and top_p (like curl)
print("\nTest 2: WITHOUT temperature and top_p (matching curl)")
payload2 = {
"team_id": TEAM_ID,
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
"messages": [{"role": "user", "content": "Say hi"}],
"max_tokens": 50
}
with httpx.Client(timeout=30) as client:
response = client.post(API_ENDPOINT, headers=headers, json=payload2)
print(f"Status: {response.status_code}")
if response.is_success:
print(f"✓ SUCCESS!")
print(f"Response: {response.json()}")
else:
print(f"✗ Error: {response.text}")