mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-07 22:36:02 +00:00
adjust:修改,去除neko.json,以及一些占位的变量等
This commit is contained in:
@@ -69,7 +69,7 @@ def set_to_default():
|
||||
__current__ = list(default_dict.keys())[0]
|
||||
|
||||
|
||||
def get_prompt(name: str = None) -> str:
|
||||
def get_prompt(name: str = None) -> list:
|
||||
import config
|
||||
preset_mode = config.preset_mode
|
||||
|
||||
@@ -89,7 +89,7 @@ def get_prompt(name: str = None) -> str:
|
||||
with open(json_file, 'r', encoding ='utf-8') as f:
|
||||
json_content = json.load(f)
|
||||
logging.debug('succeed to load json: {}'.format(json_file))
|
||||
return json_content['prompt'], json_content['name'], json_content['filter']
|
||||
return json_content['prompt']
|
||||
|
||||
except FileNotFoundError:
|
||||
|
||||
@@ -111,6 +111,6 @@ def get_prompt(name: str = None) -> str:
|
||||
"role":"assistant",
|
||||
"content":"好的。"
|
||||
}
|
||||
], None, None
|
||||
]
|
||||
|
||||
raise KeyError("未找到默认情景预设: " + name)
|
||||
|
||||
@@ -135,7 +135,6 @@ class Session:
|
||||
use_default = dprompt.get_current()
|
||||
|
||||
current_default_prompt = dprompt.get_prompt(use_default)
|
||||
# 返回一个元组:(prompt, name, filter)
|
||||
return current_default_prompt
|
||||
|
||||
def __init__(self, name: str):
|
||||
@@ -146,8 +145,7 @@ class Session:
|
||||
|
||||
self.response_lock = threading.Lock()
|
||||
|
||||
#更改了返回值,后两个变量给机器人名字和过滤器占位
|
||||
self.prompt, a, b = self.get_default_prompt()
|
||||
self.prompt = self.get_default_prompt()
|
||||
logging.debug("prompt is: {}".format(self.prompt))
|
||||
|
||||
# 设定检查session最后一次对话是否超过过期时间的计时器
|
||||
@@ -192,7 +190,7 @@ class Session:
|
||||
self.last_interact_timestamp = int(time.time())
|
||||
|
||||
# 触发插件事件
|
||||
if self.prompt == self.get_default_prompt()[0]:
|
||||
if self.prompt == self.get_default_prompt():
|
||||
args = {
|
||||
'session_name': self.name,
|
||||
'session': self,
|
||||
@@ -275,7 +273,7 @@ class Session:
|
||||
|
||||
# 持久化session
|
||||
def persistence(self):
|
||||
if self.prompt == self.get_default_prompt()[0]:
|
||||
if self.prompt == self.get_default_prompt():
|
||||
return
|
||||
|
||||
db_inst = pkg.utils.context.get_database_manager()
|
||||
@@ -306,8 +304,8 @@ class Session:
|
||||
|
||||
if expired:
|
||||
pkg.utils.context.get_database_manager().set_session_expired(self.name, self.create_timestamp)
|
||||
# a, b为bot_name和bot_filter占位变量
|
||||
self.prompt, a, b = self.get_default_prompt(use_prompt)
|
||||
|
||||
self.prompt = self.get_default_prompt(use_prompt)
|
||||
self.create_timestamp = int(time.time())
|
||||
self.last_interact_timestamp = int(time.time())
|
||||
self.just_switched_to_exist_session = False
|
||||
|
||||
Reference in New Issue
Block a user