fix: contact_folder_service db.refresh after commit + AI stream own DB session in generator
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
This commit is contained in:
@@ -578,10 +578,15 @@ async def chat_stream(
|
||||
}
|
||||
|
||||
async def event_stream():
|
||||
async for chunk in stream_chat(
|
||||
db, session, agent, data.content, user_context, tenant_id
|
||||
):
|
||||
yield chunk
|
||||
# Use a fresh DB session — the Depends(get_db) session closes after response
|
||||
from app.core.db import get_session_factory
|
||||
factory = get_session_factory()
|
||||
async with factory() as stream_db:
|
||||
await set_tenant_context(stream_db, tenant_id)
|
||||
async for chunk in stream_chat(
|
||||
stream_db, session, agent, data.content, user_context, tenant_id
|
||||
):
|
||||
yield chunk
|
||||
yield "data: [DONE]\n\n"
|
||||
|
||||
return StreamingResponse(
|
||||
|
||||
Reference in New Issue
Block a user