mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-19 09:14:03 +00:00
refactor: ChannelManager creates and injects GatewayHTTPHandler
This commit is contained in:
parent
e5eb08e3e5
commit
1252550649
@ -16,6 +16,7 @@ from nanobot.bus.queue import MessageBus
|
|||||||
from nanobot.channels.base import BaseChannel
|
from nanobot.channels.base import BaseChannel
|
||||||
from nanobot.config.schema import Config
|
from nanobot.config.schema import Config
|
||||||
from nanobot.utils.restart import consume_restart_notice_from_env, format_restart_completed_message
|
from nanobot.utils.restart import consume_restart_notice_from_env, format_restart_completed_message
|
||||||
|
from nanobot.webui.ws_http import GatewayHTTPHandler
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from nanobot.session.manager import SessionManager
|
from nanobot.session.manager import SessionManager
|
||||||
@ -111,17 +112,22 @@ class ChannelManager:
|
|||||||
try:
|
try:
|
||||||
kwargs: dict[str, Any] = {}
|
kwargs: dict[str, Any] = {}
|
||||||
if cls.name == "websocket":
|
if cls.name == "websocket":
|
||||||
if self._session_manager is not None:
|
from nanobot.channels.websocket import WebSocketConfig
|
||||||
kwargs["session_manager"] = self._session_manager
|
|
||||||
static_path = _default_webui_dist() if self._webui_static_dist else None
|
parsed = WebSocketConfig.model_validate(section)
|
||||||
if static_path is not None:
|
static_path = _default_webui_dist() if self._webui_static_dist else None
|
||||||
kwargs["static_dist_path"] = static_path
|
workspace = Path(self.config.workspace_path)
|
||||||
kwargs["workspace_path"] = self.config.workspace_path
|
http_handler = GatewayHTTPHandler(
|
||||||
kwargs["restrict_to_workspace"] = self.config.tools.restrict_to_workspace
|
config=parsed,
|
||||||
if self._webui_runtime_model_name is not None:
|
session_manager=self._session_manager,
|
||||||
kwargs["runtime_model_name"] = self._webui_runtime_model_name
|
static_dist_path=static_path,
|
||||||
kwargs["runtime_surface"] = self._webui_runtime_surface
|
workspace_path=workspace,
|
||||||
kwargs["runtime_capabilities_overrides"] = self._webui_runtime_capabilities
|
runtime_model_name=self._webui_runtime_model_name,
|
||||||
|
runtime_surface=self._webui_runtime_surface,
|
||||||
|
runtime_capabilities_overrides=self._webui_runtime_capabilities,
|
||||||
|
bus=self.bus,
|
||||||
|
)
|
||||||
|
kwargs["http_handler"] = http_handler
|
||||||
channel = cls(section, self.bus, **kwargs)
|
channel = cls(section, self.bus, **kwargs)
|
||||||
channel.transcription_provider = transcription_provider
|
channel.transcription_provider = transcription_provider
|
||||||
channel.transcription_api_key = transcription_key
|
channel.transcription_api_key = transcription_key
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user