feat & refactor: 重构agents目录结构;AI回复模块agent结构封装

This commit is contained in:
yangshilin
2026-03-19 10:36:55 +08:00
parent b56fc859cc
commit b16bb2b96c
14 changed files with 754 additions and 781 deletions

View File

@@ -14,7 +14,7 @@ from database import get_async_db
from database.models import Chapter as ChapterModel, ChapterSection
from database.models import User as UserModel
from middleware.auth import get_current_user
from agents.prompts.memory_prompts import CHAPTER_CATEGORIES, CHAPTER_ORDER, STAGE_TO_ORDER
from app.agents.prompts.memory_prompts import CHAPTER_CATEGORIES, CHAPTER_ORDER, STAGE_TO_ORDER
from services.memoir_images.schema import (
completed_image_assets,
IMAGE_STATUS_COMPLETED,

View File

@@ -15,15 +15,15 @@ from starlette.websockets import WebSocketState
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from agents import ConversationAgent, MemoryAgent
from agents.memoir_processor import BackgroundTaskRunner
from app.agents import ConversationAgent, MemoryAgent
from app.agents.memoir import BackgroundTaskRunner
from database import get_async_db
from database.models import Conversation, Segment
from database.models import User as UserModel
from services.auth_service import verify_token
from services.memoir_state_service import get_or_create_state
from services import asr_service, redis_service
from agents.prompts.profile_prompts import format_user_profile_context
from app.agents.prompts.profile_prompts import format_user_profile_context
logger = logging.getLogger(__name__)
LEGACY_VOICE_SESSION_ID = "legacy"
@@ -924,7 +924,7 @@ async def websocket_endpoint(
def _get_missing_profile_fields(user: UserModel) -> list:
"""检查用户缺失的资料字段"""
from agents.prompts.profile_prompts import get_missing_profile_fields
from app.agents.prompts.profile_prompts import get_missing_profile_fields
return get_missing_profile_fields(
birth_year=user.birth_year,
birth_place=user.birth_place,
@@ -935,7 +935,7 @@ def _get_missing_profile_fields(user: UserModel) -> list:
def _get_filled_profile_fields(user: UserModel) -> dict:
"""获取用户已有的资料字段(中文展示)"""
from agents.prompts.profile_prompts import PROFILE_FIELD_NAMES
from app.agents.prompts.profile_prompts import PROFILE_FIELD_NAMES
filled = {}
if user.birth_year:
filled["birth_year"] = str(user.birth_year)
@@ -1045,7 +1045,7 @@ async def process_user_message(
# 构建用户资料上下文
user_profile_context = ""
if user:
from agents.prompts.profile_prompts import format_user_profile_context
from app.agents.prompts.profile_prompts import format_user_profile_context
user_profile_context = format_user_profile_context(
birth_year=user.birth_year,
birth_place=user.birth_place,