支持保存历史对话, 规范代码

This commit is contained in:
2024-11-17 00:56:50 +08:00
parent 45d25b90aa
commit 690881ccae
8 changed files with 161 additions and 94 deletions

View File

@ -1,9 +1,11 @@
from .util import *
class MarshoContext:
"""
Marsho 的上下文类
"""
def __init__(self):
self.contents = {
"private": {},
@ -38,10 +40,9 @@ class MarshoContext:
def build(self, target_id: str, is_private: bool) -> list:
"""
构建返回的上下文,其中包括系统消息
构建返回的上下文,包括系统消息
"""
spell = get_prompt()
target_dict = self._get_target_dict(is_private)
if target_id not in target_dict:
target_dict[target_id] = []
return [spell] + target_dict[target_id]
return target_dict[target_id]