mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-21 03:46:11 +00:00
feat: 使用模板储存默认的json格式的情景预设
This commit is contained in:
+3
-1
@@ -11,4 +11,6 @@ prompts/
|
|||||||
logs/
|
logs/
|
||||||
sensitive.json
|
sensitive.json
|
||||||
temp/
|
temp/
|
||||||
current_tag
|
current_tag
|
||||||
|
scenario/
|
||||||
|
!scenario/default-template.json
|
||||||
@@ -332,6 +332,10 @@ if __name__ == '__main__':
|
|||||||
if not os.path.exists("sensitive.json"):
|
if not os.path.exists("sensitive.json"):
|
||||||
shutil.copy("sensitive-template.json", "sensitive.json")
|
shutil.copy("sensitive-template.json", "sensitive.json")
|
||||||
|
|
||||||
|
# 检查是否有scenario/default.json
|
||||||
|
if not os.path.exists("scenario/default.json"):
|
||||||
|
shutil.copy("scenario/default-template.json", "scenario/default.json")
|
||||||
|
|
||||||
# 检查temp目录
|
# 检查temp目录
|
||||||
if not os.path.exists("temp/"):
|
if not os.path.exists("temp/"):
|
||||||
os.mkdir("temp/")
|
os.mkdir("temp/")
|
||||||
|
|||||||
@@ -88,10 +88,8 @@ def get_prompt(name: str = None) -> list:
|
|||||||
json_content = json.load(f)
|
json_content = json.load(f)
|
||||||
logging.debug('succeed to load json: {}'.format(json_file))
|
logging.debug('succeed to load json: {}'.format(json_file))
|
||||||
return json_content['prompt']
|
return json_content['prompt']
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
raise KeyError("未找到JSON情景预设: " + name)
|
||||||
raise KeyError("未找到Json情景预设: " + name)
|
|
||||||
|
|
||||||
# 默认预设方式
|
# 默认预设方式
|
||||||
elif preset_mode == 'default':
|
elif preset_mode == 'default':
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"prompt": [
|
"prompt": [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "You are a helpful assistant. 如果我需要帮助,你要说“输入!help获得帮助”"
|
"content": "You are a helpful assistant. 如果我需要帮助,你要说“输入!help获得帮助”"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
"content": "好的,我是一个能干的AI助手。 如果你需要帮助,我会说“输入!help获得帮助”"
|
"content": "好的,我是一个能干的AI助手。 如果你需要帮助,我会说“输入!help获得帮助”"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user