feat: support session_id in current chat search
This commit is contained in:
@ -1181,6 +1181,63 @@ async def test_search_rejects_invalid_upstream_options(
|
||||
assert backend.search_calls == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_current_chat_accepts_session_id(
|
||||
config: GatewayConfig,
|
||||
) -> None:
|
||||
backend = FakeBackendClient()
|
||||
async with app_client(config, backend) as client:
|
||||
user_key = await create_user(client)
|
||||
response = await client.post(
|
||||
"/memories/search",
|
||||
json={
|
||||
"user_id": "u_123",
|
||||
"user_key": user_key,
|
||||
"session_id": "chat:c_1",
|
||||
"query": "hello",
|
||||
"scope": ["current_chat"],
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200, response.text
|
||||
assert backend.search_calls == [
|
||||
{
|
||||
"user_id": "u_123",
|
||||
"query": "hello",
|
||||
"method": "hybrid",
|
||||
"top_k": 8,
|
||||
"include_profile": True,
|
||||
"enable_llm_rerank": True,
|
||||
"app_id": "default",
|
||||
"project_id": "default",
|
||||
"filters": {"session_id": "chat:c_1"},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_rejects_conflicting_session_and_conversation_ids(
|
||||
config: GatewayConfig,
|
||||
) -> None:
|
||||
backend = FakeBackendClient()
|
||||
async with app_client(config, backend) as client:
|
||||
user_key = await create_user(client)
|
||||
response = await client.post(
|
||||
"/memories/search",
|
||||
json={
|
||||
"user_id": "u_123",
|
||||
"user_key": user_key,
|
||||
"session_id": "chat:c_1",
|
||||
"conversation_id": "c_2",
|
||||
"query": "hello",
|
||||
"scope": ["current_chat"],
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 422, response.text
|
||||
assert backend.search_calls == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_combines_custom_and_scope_filters(
|
||||
config: GatewayConfig,
|
||||
|
||||
Reference in New Issue
Block a user