workspace working

This commit is contained in:
2026-01-12 22:31:11 +08:00
parent 2738a822d1
commit 370fe6368a
149 changed files with 4648 additions and 660 deletions

55
test_clear_and_search.py Normal file
View File

@@ -0,0 +1,55 @@
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())