Spaces:
Sleeping
Sleeping
File size: 949 Bytes
4efc6f3 aab927d 4efc6f3 aab927d 4efc6f3 aab927d 5f703f9 aab927d 5f703f9 aab927d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from core.utils import load_cha_config
class ContextManager:
def __init__(self):
cha_cfg = load_cha_config("config.json")
self.user_name = cha_cfg.get("user_name", "user")
self.bot_name = cha_cfg.get("bot_name", "Tanjiro")
self.history = []
def getUserName(self) -> str:
return self.user_name
def setUserName(self, user_name):
self.user_name = user_name
def getBotName(self) -> str:
return self.bot_name
def setBotName(self, bot_name):
self.bot_name = bot_name
def getHistory(self) -> str:
return self.history
def setHistory(self, new_history: list):
self.history = new_history
# 대화 기록을 history에 추가
def addHistory(self, role: str, text: str):
self.history.append({"role": role, "text": text})
# 대화 기록 초기화
def clearHistory(self):
self.history = [] |