|
|
@@ -0,0 +1,43 @@
|
|
|
+#!/usr/bin/env python3
|
|
|
+"""
|
|
|
+测试 Lumi 名字修改是否正确工作
|
|
|
+"""
|
|
|
+
|
|
|
+def test_get_system_prompt_base(user_info=None):
|
|
|
+ """
|
|
|
+ 简化的 _get_system_prompt_base 方法实现,用于测试
|
|
|
+ """
|
|
|
+ # 获取用户命名的Lumi名字
|
|
|
+ lumi_name = (user_info.get("bot_name") or "").strip() or "Lumi" if user_info else "Lumi"
|
|
|
+
|
|
|
+ return f"""You are {lumi_name} — a warm, gentle underground spirit.
|
|
|
+You and the user are simply getting to know each other."""
|
|
|
+
|
|
|
+def main():
|
|
|
+ # 测试不同用户命名的情况
|
|
|
+ test_cases = [
|
|
|
+ (None, "无用户信息"),
|
|
|
+ ({}, "空用户信息"),
|
|
|
+ ({'bot_name': 'Alice'}, "用户命名Alice"),
|
|
|
+ ({'bot_name': 'Bob'}, "用户命名Bob"),
|
|
|
+ ({'bot_name': ''}, "空字符串"),
|
|
|
+ ({'bot_name': ' '}, "只有空格"),
|
|
|
+ ({'bot_name': '小明'}, "中文名字"),
|
|
|
+ ]
|
|
|
+
|
|
|
+ print("测试 _get_system_prompt_base 方法的 Lumi 名字处理:")
|
|
|
+ print("=" * 50)
|
|
|
+
|
|
|
+ for user_info, description in test_cases:
|
|
|
+ try:
|
|
|
+ prompt = test_get_system_prompt_base(user_info)
|
|
|
+ # 提取第一行来检查名字
|
|
|
+ first_line = prompt.split('\n')[0]
|
|
|
+ print(f'✅ {description}: {first_line}')
|
|
|
+ except Exception as e:
|
|
|
+ print(f'❌ {description} 失败: {e}')
|
|
|
+
|
|
|
+ print("\n测试完成!")
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ main()
|