mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
* 添加 长期记忆功能 * fix bugs * add memory parm for config.yaml * fix is_segment for tts * 推送主分支测试 * 🎈 perf: 美化log * 🐞 fix: bug 改用opus_next,增加文档 * 合并main到develop (#75) * fix: 多种docker build 编译方式 * fix:push * 优化打包速度 (#65) * 🐳 chore: 优化打包速度 使用国内镜像 * 🎈 perf: 优化打包速度 注释日志的时间信息 * 合并多个更新 (#68) * 🐳 chore: 优化打包速度 使用国内镜像 * 🎈 perf: 优化打包速度 注释日志的时间信息 * 🐳 chore: 改用docker hub * 🐎 ci(ci): 自动打包docker * 🐳 chore: 更新文档 * 🎈 perf: 改用opuslib_next * 🌈 style: 统一log * minimax语音tts和阿里云智能语音tts适配 * 本地模型不重复创建,共用一个 (#51) * 本地模型不重复创建,共用一个 * 更新web端页面发布版本 * 🎈 perf: 优化开发体验 (#70) 添加内置模型下载,yarn --------- Co-authored-by: TOM88812 <ttangxs0808@163.com> Co-authored-by: HonestQiao <honestqiao@163.com> Co-authored-by: 玄凤科技 <128943504+Eric0308@users.noreply.github.com> Co-authored-by: 欣南科技 <huangrongzhuang@xin-nan.com> Co-authored-by: Huang <32005838+openrz@users.noreply.github.com> * feat: support doubao online ASR * feat: support doubao online ASR --------- Co-authored-by: fofo <zhongpei@vip.qq.com> Co-authored-by: hrz <1710360675@qq.com> Co-authored-by: 玄凤科技 <128943504+Eric0308@users.noreply.github.com> Co-authored-by: kalicyh <34980061+kalicyh@users.noreply.github.com> Co-authored-by: TOM88812 <ttangxs0808@163.com> Co-authored-by: HonestQiao <honestqiao@163.com> Co-authored-by: 欣南科技 <huangrongzhuang@xin-nan.com> Co-authored-by: Huang <32005838+openrz@users.noreply.github.com> Co-authored-by: 胡垚 <qsct9501@163.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import uuid
|
|
from typing import List, Dict
|
|
from datetime import datetime
|
|
|
|
|
|
class Message:
|
|
def __init__(self, role: str, content: str = None, uniq_id: str = None):
|
|
self.uniq_id = uniq_id if uniq_id is not None else str(uuid.uuid4())
|
|
self.role = role
|
|
self.content = content
|
|
|
|
|
|
class Dialogue:
|
|
def __init__(self):
|
|
self.dialogue: List[Message] = []
|
|
# 获取当前时间
|
|
self.current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
def put(self, message: Message):
|
|
self.dialogue.append(message)
|
|
|
|
def get_llm_dialogue_with_memory(self, memory_data:str) -> List[Dict[str, str]]:
|
|
dialogue = []
|
|
|
|
for m in self.dialogue:
|
|
if m.role == "system" and len(memory_data.strip()) > 0:
|
|
content = f"{m.content}\n\n你还保留着一些长期的记忆,这有助于让你的对话更加丰富和连贯:\n<start>{memory_data}</end>"
|
|
else:
|
|
content = m.content
|
|
dialogue.append({"role": m.role, "content": content})
|
|
|
|
return dialogue
|
|
|
|
def get_llm_dialogue(self) -> List[Dict[str, str]]:
|
|
dialogue = []
|
|
for m in self.dialogue:
|
|
dialogue.append({"role": m.role, "content": m.content})
|
|
return dialogue
|