xiaozhi-esp32-server/main/xiaozhi-server/child_agent/prompt_builder.py
1530644839-rgb d7e8ed5c77 feat: document Mac server deployment and add child text dialogue
Record validated FunASR, EdgeTTS, WebSocket and incomplete LLM results; fix provider benchmark false positives; add a bounded child dialogue service using existing LLM adapters and no-key mock tests.
2026-10-10 11:12:43 +08:00

19 lines
654 B
Python

"""Build the message format accepted by existing LLM providers."""
from pathlib import Path
from typing import Mapping, Sequence
_PROMPT_FILE = Path(__file__).parent / "prompts" / "base_system.md"
def load_system_prompt() -> str:
return _PROMPT_FILE.read_text(encoding="utf-8").strip()
def build_dialogue(
user_text: str, history: Sequence[Mapping[str, str]], system_prompt: str
) -> list[dict[str, str]]:
messages = [{"role": "system", "content": system_prompt}]
messages.extend({"role": item["role"], "content": item["content"]} for item in history)
messages.append({"role": "user", "content": user_text})
return messages