修改了nanobot,往Hermes agent的风格走,进度1/3
This commit is contained in:
27
app-instance/backend/beaver/interfaces/web/deps.py
Normal file
27
app-instance/backend/beaver/interfaces/web/deps.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""Web dependency wiring."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from beaver.services.agent_service import AgentService
|
||||
|
||||
try:
|
||||
from fastapi import HTTPException
|
||||
except ModuleNotFoundError: # pragma: no cover - fallback for skeleton-only environments
|
||||
class HTTPException(Exception):
|
||||
"""Minimal fallback exception matching FastAPI's constructor shape."""
|
||||
|
||||
def __init__(self, status_code: int, detail: str) -> None:
|
||||
super().__init__(detail)
|
||||
self.status_code = status_code
|
||||
self.detail = detail
|
||||
|
||||
|
||||
def get_agent_service(request: Any) -> AgentService:
|
||||
"""从 app state 里取当前宿主层托管的 AgentService。"""
|
||||
|
||||
service = getattr(request.app.state, "agent_service", None)
|
||||
if not isinstance(service, AgentService):
|
||||
raise HTTPException(status_code=503, detail="AgentService is not ready")
|
||||
return service
|
||||
Reference in New Issue
Block a user