-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_test.py
More file actions
92 lines (74 loc) · 2.27 KB
/
Copy pathquick_test.py
File metadata and controls
92 lines (74 loc) · 2.27 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
Quick Test - Single API Call
Tests the chatbot with a simple request
"""
import requests
import json
BASE_URL = "http://localhost:5000"
# Test 1: Health Check
print("=" * 60)
print("TEST 1: Health Check")
print("=" * 60)
response = requests.get(f"{BASE_URL}/health")
print(json.dumps(response.json(), indent=2))
# Test 2: Simple Chat
print("\n" + "=" * 60)
print("TEST 2: Simple Chat")
print("=" * 60)
print("User: Hello! What can you help me with?")
payload = {
"message": "Hello! What can you help me with?",
"session_id": "quick_test"
}
response = requests.post(
f"{BASE_URL}/chat",
headers={"Content-Type": "application/json"},
json=payload
)
result = response.json()
if result.get("success"):
print(f"\n🤖 Bot: {result['response']}")
print(f"\n📊 Tokens: {result['usage']['prompt_tokens']} prompt + {result['usage']['completion_tokens']} completion")
else:
print(f"Error: {result.get('error')}")
# Test 3: Follow-up Question
print("\n" + "=" * 60)
print("TEST 3: Follow-up with Memory")
print("=" * 60)
print("User: Can you explain REST APIs in one sentence?")
payload = {
"message": "Can you explain REST APIs in one sentence?",
"session_id": "quick_test"
}
response = requests.post(f"{BASE_URL}/chat", json=payload)
result = response.json()
if result.get("success"):
print(f"\n🤖 Bot: {result['response']}")
else:
print(f"Error: {result.get('error')}")
# Test 4: Pirate Mode
print("\n" + "=" * 60)
print("TEST 4: Dynamic Prompt Change (Pirate Mode)")
print("=" * 60)
# Update to pirate mode
config_payload = {
"system_prompt": "You are a friendly pirate assistant. Always speak like a pirate using 'Ahoy!', 'matey', 'arr', etc."
}
requests.post(f"{BASE_URL}/config", json=config_payload)
print("Updated system prompt to Pirate Mode")
# Clear session for fresh start
requests.delete(f"{BASE_URL}/session/pirate_test")
print("\nUser: Hello! Who are you?")
payload = {
"message": "Hello! Who are you?",
"session_id": "pirate_test"
}
response = requests.post(f"{BASE_URL}/chat", json=payload)
result = response.json()
if result.get("success"):
print(f"\n🏴☠️ Pirate Bot: {result['response']}")
else:
print(f"Error: {result.get('error')}")
print("\n" + "=" * 60)
print("✅ All tests completed!")
print("=" * 60)