ReMe/test/http_client_test.py
jinli.yl 074634d884 refactor(reme_ai): consolidate personal memory and update related ops
- Rename and restructure personal memory consolidation flow
- Update memory handling in context and operations
- Refactor memory schema to use time_created and time_modified fields
- Improve error handling and logging in memory operations
- Update test cases for new memory consolidation flow
2025-08-28 14:31:03 +08:00

127 lines
3.6 KiB
Python

import asyncio
import json
import aiohttp
base_url = "http://0.0.0.0:8002"
async def run1(session):
workspace_id = "default1"
async with session.post(
f"{base_url}/vector_store",
json={
"action": "delete",
"workspace_id": workspace_id,
},
headers={"Content-Type": "application/json"}
) as response:
result = await response.json()
print(json.dumps(result, ensure_ascii=False))
trajectories = [
{
"task_id": "t1",
"messages": [
{"role": "user", "content": "搜索可以使用websearch工具"}
],
"score": 1,
},
{
"task_id": "t1",
"messages": [
{"role": "user", "content": "搜索可以使用code工具"}
],
"score": 0,
}
]
async with session.post(
# f"{base_url}/summary_task_memory",
f"{base_url}/summary_task_memory_simple",
json={
"trajectories": trajectories,
"workspace_id": workspace_id,
},
headers={"Content-Type": "application/json"}
) as response:
result = await response.json()
print(json.dumps(result, ensure_ascii=False))
await asyncio.sleep(2)
async with session.post(
# f"{base_url}/retrieve_task_memory",
f"{base_url}/retrieve_task_memory_simple",
json={
"query": "茅台怎么样?",
"workspace_id": workspace_id,
},
headers={"Content-Type": "application/json"}
) as response:
result = await response.json()
print(json.dumps(result, ensure_ascii=False))
async def run2(session):
workspace_id = "default2"
async with session.post(
f"{base_url}/vector_store",
json={
"action": "delete",
"workspace_id": workspace_id,
},
headers={"Content-Type": "application/json"}
) as response:
result = await response.json()
print(json.dumps(result, ensure_ascii=False))
messages = [{"role": "user", "content": "我喜欢吃西瓜🍉"}]
async with session.post(
f"{base_url}/summary_personal_memory",
json={
"messages": messages,
"workspace_id": workspace_id,
},
headers={"Content-Type": "application/json"}
) as response:
result = await response.json()
print(json.dumps(result, ensure_ascii=False))
await asyncio.sleep(2)
async with session.post(
f"{base_url}/retrieve_personal_memory",
json={
"query": "茅台怎么样?",
"workspace_id": workspace_id,
},
headers={"Content-Type": "application/json"}
) as response:
result = await response.json()
print(json.dumps(result, ensure_ascii=False))
async def main():
async with aiohttp.ClientSession() as session:
# 获取工具列表
print("获取工具列表...")
async with session.get(f"{base_url}/list") as response:
if response.status == 200:
tools = await response.json()
print("可用工具:")
for tool in tools:
print(json.dumps(tool, ensure_ascii=False))
else:
print(f"获取工具列表失败: {response.status}")
return
# await run1(session)
await run2(session)
if __name__ == "__main__":
asyncio.run(main())