2026-04-02 12:00:00 +08:00
|
|
|
|
"""Bundled parameters for chat system prompts (InterviewAgent)."""
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
from typing import Dict, List, Optional
|
|
|
|
|
|
|
2026-04-10 13:56:44 +08:00
|
|
|
|
from app.agents.chat.interview_turn_plan import InterviewTurnPlan
|
2026-04-08 21:36:12 +08:00
|
|
|
|
from app.agents.state_schema import KnownFact, PersonaThread
|
|
|
|
|
|
|
2026-04-02 12:00:00 +08:00
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
|
|
class ChatPromptContext:
|
|
|
|
|
|
"""访谈轮次构建 `get_guided_conversation_prompt` 所需的字段集合。"""
|
|
|
|
|
|
|
|
|
|
|
|
current_stage: str
|
|
|
|
|
|
empty_slots: List[str]
|
|
|
|
|
|
filled_slots: Dict[str, str]
|
|
|
|
|
|
all_stages_coverage: Optional[Dict[str, Dict]] = None
|
|
|
|
|
|
detected_user_stage: str = ""
|
|
|
|
|
|
user_profile_context: str = ""
|
|
|
|
|
|
persona: str = "default"
|
|
|
|
|
|
memory_evidence_text: str = ""
|
|
|
|
|
|
background_voice: str = "default"
|
|
|
|
|
|
occupation: str = ""
|
2026-04-08 15:37:09 +08:00
|
|
|
|
profile_birth_year: int | None = None
|
|
|
|
|
|
profile_era_place: str = ""
|
2026-04-08 21:36:12 +08:00
|
|
|
|
known_facts: List[KnownFact] | None = None
|
|
|
|
|
|
persona_threads: List[PersonaThread] | None = None
|
|
|
|
|
|
recent_questions: List[str] | None = None
|
2026-04-10 13:56:44 +08:00
|
|
|
|
turn_plan: InterviewTurnPlan | None = None
|
2026-04-02 12:00:00 +08:00
|
|
|
|
|
|
|
|
|
|
def guided_system_prompt(self) -> str:
|
2026-04-22 16:56:28 +08:00
|
|
|
|
"""用户原话仅以对话历史 + HumanMessage 注入模型。
|
|
|
|
|
|
|
|
|
|
|
|
本轮模式硬指令统一由 `InterviewTurnPlan.render_system_directive()` 产出,
|
|
|
|
|
|
主 prompt 不得重复立法(见 interview_turn_plan 模块 docstring)。
|
|
|
|
|
|
"""
|
2026-04-02 12:00:00 +08:00
|
|
|
|
from app.agents.chat.prompts_conversation import get_guided_conversation_prompt
|
|
|
|
|
|
|
2026-04-10 13:56:44 +08:00
|
|
|
|
directive = (
|
2026-04-22 16:56:28 +08:00
|
|
|
|
self.turn_plan.render_system_directive()
|
2026-04-10 13:56:44 +08:00
|
|
|
|
if self.turn_plan is not None
|
|
|
|
|
|
else ""
|
|
|
|
|
|
)
|
2026-04-02 12:00:00 +08:00
|
|
|
|
return get_guided_conversation_prompt(
|
|
|
|
|
|
current_stage=self.current_stage,
|
|
|
|
|
|
empty_slots=self.empty_slots,
|
|
|
|
|
|
filled_slots=self.filled_slots,
|
|
|
|
|
|
all_stages_coverage=self.all_stages_coverage,
|
|
|
|
|
|
detected_user_stage=self.detected_user_stage,
|
|
|
|
|
|
user_profile_context=self.user_profile_context,
|
|
|
|
|
|
persona=self.persona,
|
|
|
|
|
|
memory_evidence_text=self.memory_evidence_text,
|
|
|
|
|
|
background_voice=self.background_voice,
|
|
|
|
|
|
occupation=self.occupation,
|
2026-04-08 15:37:09 +08:00
|
|
|
|
profile_birth_year=self.profile_birth_year,
|
|
|
|
|
|
profile_era_place=self.profile_era_place,
|
2026-04-08 21:36:12 +08:00
|
|
|
|
known_facts=self.known_facts or [],
|
|
|
|
|
|
persona_threads=self.persona_threads or [],
|
|
|
|
|
|
recent_questions=self.recent_questions or [],
|
2026-04-10 13:56:44 +08:00
|
|
|
|
turn_directive_block=directive,
|
2026-04-02 12:00:00 +08:00
|
|
|
|
)
|