mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-07 14:52:39 +02:00
feat(chat): add multi-agent mode routing scaffold and telemetry.
This commit is contained in:
parent
78f71c7e3a
commit
7b9a218d62
13 changed files with 742 additions and 58 deletions
47
surfsense_backend/app/tasks/chat/stream_dispatch.py
Normal file
47
surfsense_backend/app/tasks/chat/stream_dispatch.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"""Thin architecture dispatch seam for chat streaming entrypoints."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
from typing import Any
|
||||
|
||||
from app.agents.multi_agent_v1.entrypoint import MultiAgentEntrypoint
|
||||
from app.agents.new_chat.architecture_mode import (
|
||||
ArchitectureMode,
|
||||
parse_architecture_mode,
|
||||
)
|
||||
from app.tasks.chat.stream_new_chat import stream_new_chat, stream_resume_chat
|
||||
|
||||
|
||||
def _resolve_mode(mode_value: str) -> ArchitectureMode:
|
||||
return parse_architecture_mode(mode_value) or ArchitectureMode.SINGLE_AGENT
|
||||
|
||||
|
||||
def dispatch_new_chat_stream(
|
||||
*,
|
||||
architecture_mode: str,
|
||||
stream_kwargs: dict[str, Any],
|
||||
) -> AsyncGenerator[str, None]:
|
||||
mode = _resolve_mode(architecture_mode)
|
||||
if mode == ArchitectureMode.SINGLE_AGENT:
|
||||
return stream_new_chat(**stream_kwargs)
|
||||
entrypoint = MultiAgentEntrypoint()
|
||||
return entrypoint.stream_new_chat(
|
||||
fallback_streamer=stream_new_chat,
|
||||
fallback_kwargs=stream_kwargs,
|
||||
)
|
||||
|
||||
|
||||
def dispatch_resume_chat_stream(
|
||||
*,
|
||||
architecture_mode: str,
|
||||
stream_kwargs: dict[str, Any],
|
||||
) -> AsyncGenerator[str, None]:
|
||||
mode = _resolve_mode(architecture_mode)
|
||||
if mode == ArchitectureMode.SINGLE_AGENT:
|
||||
return stream_resume_chat(**stream_kwargs)
|
||||
entrypoint = MultiAgentEntrypoint()
|
||||
return entrypoint.stream_resume_chat(
|
||||
fallback_streamer=stream_resume_chat,
|
||||
fallback_kwargs=stream_kwargs,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue