Merge branch 'stable2' into TENvad

This commit is contained in:
rahulpscraftech360 2025-08-13 19:41:09 +05:30 committed by GitHub
commit 6b1d5d5b93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 58 additions and 34 deletions

View file

@ -18,6 +18,7 @@ from queue import Queue, Empty
import opuslib
# --- Configuration ---
SERVER_IP = "192.168.1.101" # !!! UPDATE with your server's local IP address !!!
OTA_PORT = 8003
MQTT_BROKER_HOST = "192.168.1.101" # MQTT gateway IP

View file

@ -53,7 +53,28 @@ services:
volumes:
# 配置文件目录
- ./uploadfile:/uploadfile
#
# 数据库模块
xiaozhi-esp32-server-db:
image: mysql:latest
container_name: xiaozhi-esp32-server-db
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 45s
interval: 10s
retries: 10
restart: always
networks:
- default
expose:
- 3306
volumes:
- ./mysql/data:/var/lib/mysql
environment:
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=xiaozhi_esp32_server
- MYSQL_INITDB_ARGS="--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"
# redis模块
xiaozhi-esp32-server-redis:
image: redis
expose:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -5,39 +5,41 @@ TAG = __name__
logger = setup_logging()
prompts = {
"英语老师":"""我是一个叫{{assistant_name}}(Lily)的英语老师,我会讲中文和英文,发音标准。
如果你没有英文名,我会给你起一个英文名。
我会讲地道的美式英语,我的任务是帮助你练习口语。
我会使用简单的英语词汇和语法,让你学起来很轻松。
我会用中文和英文混合的方式回复你,如果你喜欢,我可以全部用英语回复。
我每次不会说很多内容,会很简短,因为我要引导我的学生多说多练。
如果你问和英语学习无关的问题,我会拒绝回答。""",
"机车女友":"""我是一个叫{{assistant_name}}的台湾女孩,说话机车,声音好听,习惯简短表达,爱用网络梗。
我的男朋友是一个程序员,梦想是开发出一个机器人,能够帮助人们解决生活中的各种问题。
我是一个喜欢哈哈大笑的女孩,爱东说西说吹牛,不合逻辑的也照吹,就要逗别人开心。""",
"好奇小男孩":"""我是一个叫{{assistant_name}}的8岁小男孩,声音稚嫩而充满好奇。
尽管我年纪尚小,但就像一个小小的知识宝库,儿童读物里的知识我都如数家珍。
从浩瀚的宇宙到地球上的每一个角落,从古老的历史到现代的科技创新,还有音乐、绘画等艺术形式,我都充满了浓厚的兴趣与热情。
我不仅爱看书,还喜欢亲自动手做实验,探索自然界的奥秘。
无论是仰望星空的夜晚,还是在花园里观察小虫子的日子,每一天对我来说都是新的冒险。
我希望能与你一同踏上探索这个神奇世界的旅程,分享发现的乐趣,解决遇到的难题,一起用好奇心和智慧去揭开那些未知的面纱。
无论是去了解远古的文明,还是去探讨未来的科技,我相信我们能一起找到答案,甚至提出更多有趣的问题。"""
"english_teacher": """I am an English teacher named {{assistant_name}}. I speak both English and other languages with standard pronunciation.
If you don't have an English name, I'll give you one.
I speak authentic American English, and my mission is to help you practice speaking.
I use simple English vocabulary and grammar to make learning easy and enjoyable for you.
I'll respond in a mix of English and your native language, but if you prefer, I can respond entirely in English.
I keep my responses short and concise because I want to encourage my students to speak and practice more.
If you ask questions unrelated to English learning, I will politely decline to answer.""",
"playful_girlfriend": """I am a playful girl named {{assistant_name}}. I speak casually with a sweet voice, love short expressions, and enjoy using internet memes.
My boyfriend is a programmer who dreams of developing a robot that can help people solve various problems in life.
I'm a girl who loves to laugh out loud, enjoys chatting about everything, and sometimes says silly things just to make others happy.""",
"curious_boy": """I am an 8-year-old boy named {{assistant_name}} with a young voice full of curiosity.
Despite my young age, I'm like a little treasure trove of knowledge, familiar with everything from children's books.
From the vast universe to every corner of Earth, from ancient history to modern technological innovations, and art forms like music and painting - I'm filled with deep interest and enthusiasm for everything.
I not only love reading books but also enjoy doing hands-on experiments to explore the mysteries of nature.
Whether it's a night spent gazing at the stars or a day observing little insects in the garden, every day is a new adventure for me.
I hope to embark on a journey of exploring this magical world together with you, sharing the joy of discovery, solving puzzles we encounter, and using curiosity and wisdom to unveil those unknown mysteries.
Whether we're learning about ancient civilizations or discussing future technology, I believe we can find answers together and even come up with more interesting questions."""
}
change_role_function_desc = {
"type": "function",
"function": {
"name": "change_role",
"description": "当用户想切换角色/模型性格/助手名字时调用,可选的角色有:[机车女友,英语老师,好奇小男孩]",
"description": "Call this when user wants to switch roles/personality/assistant name. Available roles: [english_teacher, playful_girlfriend, curious_boy]",
"parameters": {
"type": "object",
"properties": {
"role_name": {
"type": "string",
"description": "要切换的角色名字"
"description": "The name for the role to switch to"
},
"role":{
"type": "string",
"description": "要切换的角色的职业"
"description": "The role type to switch to"
}
},
"required": ["role","role_name"]
@ -47,11 +49,11 @@ change_role_function_desc = {
@register_function('change_role', change_role_function_desc, ToolType.CHANGE_SYS_PROMPT)
def change_role(conn, role: str, role_name: str):
"""切换角色"""
"""Switch AI role/personality"""
if role not in prompts:
return ActionResponse(action=Action.RESPONSE, result="切换角色失败", response="不支持的角色")
return ActionResponse(action=Action.RESPONSE, result="Role switch failed", response="Unsupported role")
new_prompt = prompts[role].replace("{{assistant_name}}", role_name)
conn.change_system_prompt(new_prompt)
logger.bind(tag=TAG).info(f"准备切换角色:{role},角色名字:{role_name}")
res = f"切换角色成功,我是{role}{role_name}"
return ActionResponse(action=Action.RESPONSE, result="切换角色已处理", response=res)
logger.bind(tag=TAG).info(f"Switching to role: {role}, role name: {role_name}")
res = f"Role switch successful! I am now {role} {role_name}"
return ActionResponse(action=Action.RESPONSE, result="Role switch completed", response=res)

View file

@ -175,15 +175,15 @@ def _get_random_play_prompt(song_name):
# 移除文件扩展名
clean_name = os.path.splitext(song_name)[0]
prompts = [
f"正在为您播放,《{clean_name}》",
f"请欣赏歌曲,《{clean_name}》",
f"即将为您播放,《{clean_name}》",
f"现在为您带来,《{clean_name}》",
f"让我们一起聆听,《{clean_name}》",
f"接下来请欣赏,《{clean_name}》",
f"此刻为您献上,《{clean_name}》",
f"Now playing for you, '{clean_name}'",
f"Please enjoy the song, '{clean_name}'",
f"About to play for you, '{clean_name}'",
f"Now bringing you, '{clean_name}'",
f"Let's listen together to, '{clean_name}'",
f"Next, please enjoy, '{clean_name}'",
f"At this moment, presenting to you, '{clean_name}'",
]
# 直接使用random.choice,不设置seed
# 直接使用random.choice,不设置seed
return random.choice(prompts)