refactor: 重命名 agent_chat 模块为 agent
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from core.agent_chat.event_bridge import map_internal_event
|
||||
from core.agent.event_bridge import map_internal_event
|
||||
|
||||
|
||||
class AguiAdapter:
|
||||
+1
-1
@@ -17,7 +17,7 @@ class CrewAITemplate:
|
||||
|
||||
|
||||
def _default_static_root() -> Path:
|
||||
return Path(__file__).resolve().parents[3] / "config" / "static" / "agent_chat"
|
||||
return Path(__file__).resolve().parents[3] / "config" / "static" / "agent"
|
||||
|
||||
|
||||
def _read_yaml(file_path: Path) -> dict[str, Any]:
|
||||
@@ -5,7 +5,7 @@ import hashlib
|
||||
from pathlib import Path
|
||||
from typing import Protocol
|
||||
|
||||
from core.agent_chat.storage_adapter import StorageAdapter
|
||||
from core.agent.storage_adapter import StorageAdapter
|
||||
|
||||
_ALLOWED_MIME_TYPES = {
|
||||
"audio/mpeg",
|
||||
+2
-2
@@ -4,8 +4,8 @@ import asyncio
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Awaitable, Callable
|
||||
|
||||
from core.agent_chat.cost_tracker import CostTracker
|
||||
from core.agent_chat import events
|
||||
from core.agent.cost_tracker import CostTracker
|
||||
from core.agent import events
|
||||
|
||||
StageCallable = Callable[..., Awaitable[dict[str, Any]]]
|
||||
|
||||
@@ -38,7 +38,7 @@ def _default_catalog_path() -> Path:
|
||||
Path(__file__).resolve().parents[1]
|
||||
/ "config"
|
||||
/ "static"
|
||||
/ "agent_chat"
|
||||
/ "agent"
|
||||
/ "llm_catalog.yaml"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from core.auth.models import CurrentUser
|
||||
from core.db import get_db
|
||||
from v1.agent_chat.service import AgentChatService
|
||||
from v1.agent.service import AgentChatService
|
||||
from v1.profile.dependencies import get_current_user
|
||||
|
||||
|
||||
def get_agent_chat_service(
|
||||
def get_agent_service(
|
||||
session: Annotated[AsyncSession, Depends(get_db)],
|
||||
user: Annotated[CurrentUser, Depends(get_current_user)],
|
||||
) -> AgentChatService:
|
||||
@@ -0,0 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from v1.agent.dependencies import get_agent_service
|
||||
from v1.agent.schemas import AgentChatRunRequest, AgentChatRunResponse
|
||||
from v1.agent.service import AgentChatService
|
||||
|
||||
router = APIRouter(prefix="/agent", tags=["agent"])
|
||||
|
||||
|
||||
@router.post("", response_model=AgentChatRunResponse)
|
||||
async def run_agent_chat(
|
||||
payload: AgentChatRunRequest,
|
||||
service: Annotated[AgentChatService, Depends(get_agent_service)],
|
||||
) -> AgentChatRunResponse:
|
||||
return await service.run(payload)
|
||||
@@ -9,15 +9,15 @@ from fastapi import HTTPException
|
||||
from sqlalchemy import func, select
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from core.agent_chat.agui_adapter import AguiAdapter
|
||||
from core.agent_chat.orchestrator import AgentChatOrchestrator
|
||||
from core.agent.agui_adapter import AguiAdapter
|
||||
from core.agent.orchestrator import AgentChatOrchestrator
|
||||
from core.auth.models import CurrentUser
|
||||
from core.db.base_service import BaseService
|
||||
from core.logging import get_logger
|
||||
from models.agent_chat_message import AgentChatMessage, AgentChatMessageRole
|
||||
from models.agent_chat_session import AgentChatSession, AgentChatSessionStatus
|
||||
from v1.auth.rate_limit import enforce_rate_limit
|
||||
from v1.agent_chat.schemas import (
|
||||
from v1.agent.schemas import (
|
||||
AgentChatEvent,
|
||||
AgentChatRunRequest,
|
||||
AgentChatRunResponse,
|
||||
@@ -26,7 +26,7 @@ from v1.agent_chat.schemas import (
|
||||
if TYPE_CHECKING:
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
logger = get_logger("v1.agent_chat.service")
|
||||
logger = get_logger("v1.agent.service")
|
||||
|
||||
|
||||
def build_session_title(first_message: str, *, now: datetime) -> str:
|
||||
@@ -73,7 +73,7 @@ class AgentChatService(BaseService):
|
||||
raise HTTPException(status_code=422, detail=str(exc)) from exc
|
||||
user_id = self.require_user_id()
|
||||
await enforce_rate_limit(
|
||||
scope="agent_chat_run",
|
||||
scope="agent_run",
|
||||
identifier=str(user_id),
|
||||
limit=60,
|
||||
window_seconds=60,
|
||||
@@ -1,19 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from v1.agent_chat.dependencies import get_agent_chat_service
|
||||
from v1.agent_chat.schemas import AgentChatRunRequest, AgentChatRunResponse
|
||||
from v1.agent_chat.service import AgentChatService
|
||||
|
||||
router = APIRouter(prefix="/agent-chat", tags=["agent-chat"])
|
||||
|
||||
|
||||
@router.post("", response_model=AgentChatRunResponse)
|
||||
async def run_agent_chat(
|
||||
payload: AgentChatRunRequest,
|
||||
service: Annotated[AgentChatService, Depends(get_agent_chat_service)],
|
||||
) -> AgentChatRunResponse:
|
||||
return await service.run(payload)
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from fastapi import APIRouter
|
||||
|
||||
from core.http.models import HealthResponse
|
||||
from v1.agent_chat.router import router as agent_chat_router
|
||||
from v1.agent.router import router as agent_router
|
||||
from v1.auth.router import router as auth_router
|
||||
from v1.friendships.router import router as friendships_router
|
||||
from v1.inbox_messages.router import router as inbox_messages_router
|
||||
@@ -17,7 +17,7 @@ router.include_router(auth_router)
|
||||
router.include_router(friendships_router)
|
||||
router.include_router(infra_router)
|
||||
router.include_router(users_router)
|
||||
router.include_router(agent_chat_router)
|
||||
router.include_router(agent_router)
|
||||
router.include_router(schedule_items_router)
|
||||
router.include_router(inbox_messages_router)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user