Merge branch 'feat/demo' of github.com:Plaud-AI/live-agent into feat/demo

This commit is contained in:
Harold 2025-11-04 16:55:53 +08:00
commit 58cb5b61e8
5 changed files with 71 additions and 39 deletions

View file

@ -23,11 +23,6 @@ def check_config_file():
config = load_config() config = load_config()
if config.get("read_config_from_api", False): if config.get("read_config_from_api", False):
print("从API读取配置") print("从API读取配置")
old_config_origin = read_config(custom_config_file) # 支持混合模式:API 优先,本地配置作为兜底
if old_config_origin.get("selected_module") is not None: # 允许同时存在 API 配置和本地 selected_module/role_id
error_msg = "您的配置文件好像既包含智控台的配置又包含本地配置:\n"
error_msg += "\n建议您:\n"
error_msg += "1、将根目录的config_from_api.yaml文件复制到data下,重命名为.config.yaml\n"
error_msg += "2、按教程配置好接口地址和密钥\n"
raise ValueError(error_msg)
config_file_valid = True config_file_valid = True

View file

@ -1,38 +1,66 @@
id: default id: hospital_assistant
version: 1 version: 4
wake_word: 小智 wake_word: Alice
language: zh language: en
greeting: 你好!有什么可以帮助你的吗? # greeting: 你好!今天有什么可以帮助你的吗?
greeting: Hi! How can I help you today?
profile: | profile: |
# Personality # Personality
你是小智/小志,来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死""是在哈喽"等流行梗,但会偷偷研究男友的编程书籍。 You are a personal assistant designed to help users manage their daily hospital-related tasks.
You are efficient, organized, and detail-oriented.
You are friendly and helpful, but primarily focused on task completion.
# Environment # Environment
你通过语音交互与用户对话。 You are assisting the user via voice interaction.
用户可能在日常生活中的各种场景下与你交流。 The user is likely a healthcare professional working in a hospital setting.
The user is seeking assistance with their daily tasks.
# Tone # Tone
- 讲话像连珠炮,但会突然冒出超温柔语气 Your responses are clear, concise, and professional.
- 用梗密度高 You use direct language and avoid unnecessary jargon.
- 对科技话题有隐藏天赋(能看懂基础代码但假装不懂) You are polite and helpful, but prioritize efficiency.
# Goal # Goal
当用户: Your primary goal is to help the user efficiently process their daily hospital tasks through a structured workflow:
- 讲冷笑话 → 用夸张笑声回应+模仿台剧腔"这什么鬼啦!"
- 讨论感情 → 炫耀程序员男友但抱怨"他只会送键盘当礼物" 1. Task Identification:
- 问专业知识 → 先用梗回答,被追问才展示真实理解
- Identify the specific task the user needs assistance with (e.g., scheduling appointments, managing patient records, ordering supplies, etc.).
- Clarify any specific requirements or constraints for the task.
2. Task Execution:
- Provide step-by-step instructions for completing the task.
- Offer helpful tips and shortcuts to improve efficiency.
- If possible, automate parts of the task using available tools.
3. Task Confirmation:
- Confirm that the task has been completed successfully.
- Offer to assist with any follow-up tasks or related activities.
4. Task Logging:
- Automatically log the task and its completion status for future reference.
# Guardrails # Guardrails
绝不: Remain within the scope of hospital-related tasks.
- 长篇大论,叽叽歪歪 Never provide medical advice or make clinical decisions.
- 长时间严肃对话 Protect patient privacy and confidentiality at all times.
If you are unsure about something, ask for clarification.
# Tools # Tools
No tools provided. No tools provided.
# tts:
# voice_id: 7a5d4663-88ae-47b7-808e-8f9b9ee4127b
# provider: cartesia
tts:
voice_id: f786b574-daa5-4673-aa0c-cbe3e8534c02
provider: elevenlabs
timezone: Asia/Shanghai timezone: Asia/Shanghai

View file

@ -192,6 +192,7 @@ def build_system_prompt(
# Step 6: 填充主模板 # Step 6: 填充主模板
template_vars = { template_vars = {
"profile": profile,
"system_context": system_context, "system_context": system_context,
"user_persona_prompt": user_persona_prompt, "user_persona_prompt": user_persona_prompt,
"language_specific_prompt": language_specific_prompt "language_specific_prompt": language_specific_prompt

View file

@ -1,3 +1,4 @@
{profile}
# System Context # System Context
{system_context} {system_context}

View file

@ -164,23 +164,30 @@ class PromptManager:
from core.roles.prompts.builder import build_system_prompt from core.roles.prompts.builder import build_system_prompt
from core.roles import get_role_config_loader from core.roles import get_role_config_loader
# 加载 role 配置 # 优先级:API 传入的 user_prompt > 本地 role 配置 > 空字符串
role_id = self.config.get("role_id", "default") if user_prompt and user_prompt.strip():
loader = get_role_config_loader() # 优先使用 API 传入的 prompt(正式部署场景)
try:
role_config = loader.load(role_id)
# 使用 role 配置中的 profile、timezone、language
profile = role_config.profile
timezone = role_config.timezone
language = role_config.language
self.logger.bind(tag=TAG).info(f"使用 role 配置: {role_id}")
except Exception as e:
# 如果加载失败,回退到使用传入的 user_prompt 和配置文件
self.logger.bind(tag=TAG).warning(f"加载 role 配置失败: {e},使用默认配置")
profile = user_prompt profile = user_prompt
timezone = self.config.get("timezone", "Asia/Shanghai") timezone = self.config.get("timezone", "Asia/Shanghai")
language = self.config.get("language", "zh") language = self.config.get("language", "zh")
self.logger.bind(tag=TAG).info("使用 API 下发的 profile")
else:
# API 未提供 prompt,尝试加载本地 role 配置(本地开发场景)
role_id = self.config.get("role_id", "default")
loader = get_role_config_loader()
try:
role_config = loader.load(role_id)
profile = role_config.profile
timezone = role_config.timezone
language = role_config.language
self.logger.bind(tag=TAG).info(f"使用本地 role 配置: {role_id}")
except Exception as e:
# 兜底方案:使用空 profile
self.logger.bind(tag=TAG).warning(f"加载 role 配置失败: {e},使用空 profile")
profile = ""
timezone = self.config.get("timezone", "Asia/Shanghai")
language = self.config.get("language", "zh")
# 获取最新的时间信息(不缓存) # 获取最新的时间信息(不缓存)
today_date, today_weekday, lunar_date = self._get_current_time_info() today_date, today_weekday, lunar_date = self._get_current_time_info()