| |
| """ |
| Test script for Chat History & Context Resolution (Phase 28) |
| """ |
|
|
| import asyncio |
| import json |
| import time |
| import aiohttp |
|
|
| BASE_URL = "http://localhost:8000" |
|
|
| async def test_chat_context(): |
| print("Testing Chat Context Resolution...") |
| print() |
| |
| async with aiohttp.ClientSession() as session: |
| |
| print("--- 1. Create Workflow ---") |
| async with session.post( |
| f"{BASE_URL}/api/atom-agent/chat", |
| json={ |
| "message": "Create a workflow to backup files", |
| "user_id": "test_user_context" |
| } |
| ) as resp: |
| if resp.status == 200: |
| data = await resp.json() |
| session_id = data.get("session_id") |
| response_msg = data.get('response', {}).get('message', '') |
| print(f"✅ Session created: {session_id}") |
| print(f" Response: {response_msg[:80]}...") |
| |
| |
| |
| print() |
| else: |
| print(f"❌ Failed: {resp.status}") |
| return |
| |
| |
| time.sleep(1) |
| |
| |
| print("--- 2. Schedule 'that workflow' ---") |
| async with session.post( |
| f"{BASE_URL}/api/atom-agent/chat", |
| json={ |
| "message": "Schedule that workflow every day at 2am", |
| "user_id": "test_user_context", |
| "session_id": session_id |
| } |
| ) as resp: |
| if resp.status == 200: |
| data = await resp.json() |
| response_msg = data.get('response', {}).get('message', '') |
| print(f"✅ Response: {response_msg}") |
| |
| if "Scheduled" in response_msg and "Every day at 02:00" in response_msg: |
| print("✅ SUCCESS: Context resolved and workflow scheduled!") |
| else: |
| print("❌ FAILURE: Context resolution failed or scheduling failed.") |
| print() |
| else: |
| print(f"❌ Failed: {resp.status}") |
| return |
| |
| print("--- Test completed ---") |
|
|
| if __name__ == "__main__": |
| try: |
| asyncio.run(test_chat_context()) |
| except Exception as e: |
| print(f"Error: {e}") |
|
|