File size: 1,893 Bytes
0ddd1d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastapi.testclient import TestClient
from main import app
import json

client = TestClient(app)

print("--- Testing /health ---")
try:
    resp = client.get("/health")
    print(f"Status: {resp.status_code}")
    print(f"Response: {resp.json()}")
except Exception as e:
    print(f"Failed: {e}")

print("\n--- Testing /api/v1/real-estate/chat/starters ---")
try:
    resp = client.get("/api/v1/real-estate/chat/starters")
    print(f"Status: {resp.status_code}")
    print(f"Response: {resp.json()}")
except Exception as e:
    print(f"Failed: {e}")

messages = [
    "Hello there!",
    "What does the 7-day average mean?",
    "Can you export the market averages for Miami to a CSV file?"
]

print("\n--- Testing /api/v1/real-estate/chat ---")

# First, test isolated queries
for i, msg in enumerate(messages):
    print(f"\nTest {i+1}: '{msg}'")
    try:
        payload = {"message": msg, "session_id": f"isolated_session_{i}"}
        resp = client.post("/api/v1/real-estate/chat", json=payload)
        print(f"Status: {resp.status_code}")
        print(f"Response: {json.dumps(resp.json(), indent=2)}")
    except Exception as e:
        print(f"Failed: {e}")

# Next, test multi-turn conversation
print("\n--- Testing Multi-Turn Conversation & Memory ---")
multi_turn_msgs = [
    "What's the market average for Miami?",
    "Can you export that data into a CSV file for me?",
    "Are there any other markets you track? I'm not sure which one I want."
]
session_id = "multi_turn_test_session_1"

for i, msg in enumerate(multi_turn_msgs):
    print(f"\nTurn {i+1}: '{msg}'")
    try:
        payload = {"message": msg, "session_id": session_id}
        resp = client.post("/api/v1/real-estate/chat", json=payload)
        print(f"Status: {resp.status_code}")
        print(f"Response: {json.dumps(resp.json(), indent=2)}")
    except Exception as e:
        print(f"Failed: {e}")