refactor(eval+memoir):精简内部评测路由与服务,composite/对话摘要与 judge 能力补强

- 访谈:新增 interview_state_hints,联动 orchestrator 与提示词
- 回忆录:story_pipeline_sync/state/memory/post_commit 与 Celery 任务调整
- 基建:开发用 celery broker、compose/development 脚本、依赖注入
- eval-web:移除数据集/实验/版本等页面与流式轮询,突出 Playground
- 文档与单测同步
This commit is contained in:
Kevin
2026-04-08 21:36:12 +08:00
parent 2a0c80987d
commit 064ad2161d
64 changed files with 3412 additions and 3068 deletions

View File

@@ -12,6 +12,10 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.agents.chat.agent_turn import AgentChatTurn
from app.agents.chat.helpers import get_history_with_window
from app.agents.chat.interview_agent import InterviewAgent
from app.agents.chat.interview_state_hints import (
build_runtime_interview_state,
extract_scene_cues,
)
from app.agents.chat.profile_agent import ProfileAgent
from app.agents.chat.stage_detection import (
detect_primary_life_stage,
@@ -23,7 +27,11 @@ from app.core.config import settings
from app.core.dependencies import get_llm_provider
from app.core.logging import get_logger
from app.features.conversation.input_normalize import normalize_chat_input_for_agent
from app.features.memoir.state_service import get_or_create_state, switch_stage
from app.features.memoir.state_service import (
get_or_create_state,
save_interview_state_meta,
switch_stage,
)
def _llm_for_chat_input_normalize():
@@ -275,6 +283,13 @@ class ChatOrchestrator:
memory_evidence_text, mem_trace = await _fetch_interview_memory_evidence(
db, user_id, normalized_user_message
)
scene_cues = extract_scene_cues(normalized_user_message)
if scene_cues:
cue_block = "\n".join(f"- {c}" for c in scene_cues)
scene_hint = (
f"\n\n[场景氛围提示——可借用这些感官细节自然接话,不要原样抄]\n{cue_block}"
)
memory_evidence_text = (memory_evidence_text or "") + scene_hint
profile_birth_year = user.birth_year if user else None
profile_era_place = ""
@@ -282,11 +297,20 @@ class ChatOrchestrator:
profile_era_place = (
(user.birth_place or user.grew_up_place or "").strip()
)
prompt_state = build_runtime_interview_state(
state,
user_message=normalized_user_message,
active_stage=detected or state.current_stage,
birth_year=profile_birth_year,
birth_place=(user.birth_place or "").strip() if user else "",
grew_up_place=(user.grew_up_place or "").strip() if user else "",
occupation=occupation,
)
turn = await self.interview_agent.generate_response_with_state(
conversation_id=conversation_id,
user_message=user_message,
memoir_state=state,
memoir_state=prompt_state,
user_profile_context=user_profile_context,
detected_user_stage=detected,
memory_evidence_text=memory_evidence_text,
@@ -296,6 +320,20 @@ class ChatOrchestrator:
profile_birth_year=profile_birth_year,
profile_era_place=profile_era_place,
)
recent_questions = prompt_state.recent_questions
if turn.interview_state_meta and isinstance(turn.interview_state_meta, dict):
raw_recent = turn.interview_state_meta.get("recent_questions")
if isinstance(raw_recent, list):
recent_questions = [
str(x).strip() for x in raw_recent if str(x).strip()
]
await save_interview_state_meta(
user_id,
known_facts=prompt_state.known_facts,
persona_threads=prompt_state.persona_threads,
recent_questions=recent_questions,
db=db,
)
if agent_summary_enabled():
logger.info(
"ChatOrchestrator.process_user_message route=interview "
@@ -311,6 +349,7 @@ class ChatOrchestrator:
messages=turn.messages,
skip_tts=turn.skip_tts,
memory_retrieval_trace=mem_trace,
interview_state_meta=turn.interview_state_meta,
)
return turn