mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-24 21:38:09 +02:00
refactor: streamline auth context usage across chat and automation routes
This commit is contained in:
parent
8af4a3f9d5
commit
6fd3f8570e
7 changed files with 53 additions and 28 deletions
|
|
@ -13,6 +13,7 @@ from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
|||
FilesystemSelection,
|
||||
)
|
||||
from app.agents.chat.runtime.llm_config import AgentConfig
|
||||
from app.auth.context import AuthContext
|
||||
from app.db import ChatVisibility
|
||||
from app.services.connector_service import ConnectorService
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ async def build_main_agent_for_thread(
|
|||
filesystem_selection: FilesystemSelection | None,
|
||||
disabled_tools: list[str] | None = None,
|
||||
mentioned_document_ids: list[int] | None = None,
|
||||
auth_context: AuthContext | None = None,
|
||||
) -> Any:
|
||||
return await agent_factory(
|
||||
llm=llm,
|
||||
|
|
@ -48,4 +50,5 @@ async def build_main_agent_for_thread(
|
|||
filesystem_selection=filesystem_selection,
|
||||
disabled_tools=disabled_tools,
|
||||
mentioned_document_ids=mentioned_document_ids,
|
||||
auth_context=auth_context,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
|||
FilesystemMode,
|
||||
FilesystemSelection,
|
||||
)
|
||||
from app.auth.context import AuthContext
|
||||
from app.db import ChatVisibility, async_session_maker
|
||||
from app.observability import otel as ot
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
|
|
@ -136,6 +137,7 @@ async def stream_new_chat(
|
|||
filesystem_selection: FilesystemSelection | None = None,
|
||||
request_id: str | None = None,
|
||||
user_image_data_urls: list[str] | None = None,
|
||||
auth_context: AuthContext | None = None,
|
||||
flow: Literal["new", "regenerate"] = "new",
|
||||
) -> AsyncGenerator[str, None]:
|
||||
"""Stream a new chat turn using the SurfSense deep agent.
|
||||
|
|
@ -412,6 +414,7 @@ async def stream_new_chat(
|
|||
filesystem_selection=filesystem_selection,
|
||||
disabled_tools=disabled_tools,
|
||||
mentioned_document_ids=mentioned_document_ids,
|
||||
auth_context=auth_context,
|
||||
)
|
||||
_perf_log.info(
|
||||
"[stream_new_chat] Agent created in %.3fs", time.perf_counter() - _t0
|
||||
|
|
@ -664,6 +667,7 @@ async def stream_new_chat(
|
|||
filesystem_selection=filesystem_selection,
|
||||
disabled_tools=disabled_tools,
|
||||
mentioned_document_ids=mentioned_document_ids,
|
||||
auth_context=auth_context,
|
||||
)
|
||||
_perf_log.info(
|
||||
"[stream_new_chat] Runtime rate-limit recovery repinned "
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ from app.agents.chat.multi_agent_chat.shared.filesystem_selection import (
|
|||
FilesystemMode,
|
||||
FilesystemSelection,
|
||||
)
|
||||
from app.auth.context import AuthContext
|
||||
from app.db import ChatVisibility, async_session_maker
|
||||
from app.observability import otel as ot
|
||||
from app.services.chat_session_state_service import set_ai_responding
|
||||
|
|
@ -102,6 +103,7 @@ async def stream_resume_chat(
|
|||
filesystem_selection: FilesystemSelection | None = None,
|
||||
request_id: str | None = None,
|
||||
disabled_tools: list[str] | None = None,
|
||||
auth_context: AuthContext | None = None,
|
||||
) -> AsyncGenerator[str, None]:
|
||||
"""Resume a paused HITL turn with the user's decisions.
|
||||
|
||||
|
|
@ -346,6 +348,7 @@ async def stream_resume_chat(
|
|||
thread_visibility=visibility,
|
||||
filesystem_selection=filesystem_selection,
|
||||
disabled_tools=disabled_tools,
|
||||
auth_context=auth_context,
|
||||
)
|
||||
_perf_log.info(
|
||||
"[stream_resume] Agent created in %.3fs", time.perf_counter() - _t0
|
||||
|
|
@ -481,6 +484,7 @@ async def stream_resume_chat(
|
|||
thread_visibility=visibility,
|
||||
filesystem_selection=filesystem_selection,
|
||||
disabled_tools=disabled_tools,
|
||||
auth_context=auth_context,
|
||||
)
|
||||
_perf_log.info(
|
||||
"[stream_resume] Runtime rate-limit recovery repinned "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue