import asyncio import aiohttp import json async def clear_documents(workspace): url = "http://localhost:3015/documents" headers = { "X-API-Key": "jleu1212", "X-Workspace": workspace, "accept": "application/json", } async with aiohttp.ClientSession() as session: async with session.delete(url, headers=headers) as resp: print(f"Clear status: {resp.status}") text = await resp.text() print(f"Clear response: {text}") return resp.status, text async def search(workspace): url = "http://localhost:3015/search" headers = { "Content-Type": "application/json", "X-Workspace": workspace, "X-API-Key": "jleu1212" } data = { "query": "what is the minimum safe working distance", "mode": "mix", "return_raw_data": True, "use_keywords": False } async with aiohttp.ClientSession() as session: async with session.post(url, headers=headers, json=data) as resp: print(f"Search status: {resp.status}") if resp.status == 200: result = await resp.json() print(json.dumps(result, indent=2)) else: text = await resp.text() print(f"Search error: {text}") return resp.status async def main(): workspace = "test1" print("Clearing documents...") status, _ = await clear_documents(workspace) if status == 200: print("Clear succeeded.") else: print("Clear failed.") print("Searching after clear...") await search(workspace) if __name__ == "__main__": asyncio.run(main())