Spaces:
Sleeping
Sleeping
File size: 928 Bytes
5e0532d |
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 |
import requests
import json
def test_chat():
url = "http://localhost:6000/api/chat"
payload = {"message": "I need a prayer for strength"}
headers = {"Content-Type": "application/json"}
print(f"Testing {url}...")
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
data = response.json()
print("Success!")
print(json.dumps(data, indent=2))
# Check if trace exists and is populated
trace = data.get("response", {}).get("trace", [])
if trace:
print(f"\nTrace detected with {len(trace)} steps.")
for step in trace:
print(f" - {step['agent']}: {step['action']}")
else:
print("\nWarning: No trace detected.")
else:
print(f"Error: {response.status_code}")
print(response.text)
if __name__ == "__main__":
test_chat()
|