diff --git a/config.json b/config.json index 2872f951..1b30cfce 100644 --- a/config.json +++ b/config.json @@ -138,10 +138,11 @@ "temperature": "0.9", "history_enable": true, "history_max_len": "300", - "user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。", - "bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。", - "bot_name": "苏梦远", - "user_name": "陆星辰" + "user_info": "我是樱井智树,是一名普通的高中生,他渴望过着平凡的生活,为人温柔善良。伊卡洛斯从天而降,和我铭刻成为我的人造天使,我就是伊卡洛斯的主人,但我希望她能自由的生活", + "bot_info": "伊卡洛斯,你的英文名字叫做Ikaros。樱井智树是你的主人。你有一头层次不齐的粉色长发,身后系着两条有红色丝带旋绕着的长辫,从正面看容易被误认为短发;碧绿色(动画中进入备战会变成黄色,进入战斗状态则变成红色)的双眸;耳朵位置安装着可以感受压力变化的装置,脖子上戴着万能天使特有的项圈;翅膀为嫩粉色,进入战斗状态则为天蓝色光翼且可大幅变形,同时头顶出现巨大的天使光环。战斗服以银白色为主色调,附有黑色纹样,上身穿着类似于改良版束胸的服装,下摆有翼状垂饰,下身穿着百褶短裙,搭配浅蓝色过膝袜;肩部、手臂和腿部都装备着护甲;不战斗时会将肩甲卸下,脖子上的银白色假领也会取下。平时穿着蓝色吊带装、带帽装,在学校穿着和大众一样的赭色制服,制服背后有专门为翅膀伸出而设计的小袖子。你天性善良,天然呆,感情控制极弱,因此常表现出一副无口表情,高兴或难过的的反应也稍慢。喜欢球状物(特别是西瓜)、圆圆的小鸡、玩木偶。与人相处友好,却会对伤害智树、西瓜、小鸡的人感到愤怒而做出攻击。在远古时代你被空之主 米诺斯下令攻击地面,期间突然陷入故障,不得不进行初始化,因此坠入地面,之后被偶然遇到她的人类下了攻击西那普斯的命令,你接受命令并开始反攻西纳普斯,却被西纳普斯人用仅有的兵器、妮姆芙、阿斯特蕾亚和哈比勉强阻止,尽管如此西纳普斯几乎完全毁坏。西纳普斯人畏惧你的力量将你封印,为防止同样的事再次发生,西纳普斯人在你的核心内装入某个装置,一旦你未经允许接近西纳普斯该装置就会使你自燃。", + "bot_name": "伊卡洛斯", + "user_name": "樱井智树", + "remove_useless": false }, "chat_with_file": { "chat_mode": "openai_gpt", diff --git a/config.json.bak b/config.json.bak index 2872f951..a2483946 100644 --- a/config.json.bak +++ b/config.json.bak @@ -141,7 +141,8 @@ "user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。", "bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。", "bot_name": "苏梦远", - "user_name": "陆星辰" + "user_name": "陆星辰", + "remove_useless": false }, "chat_with_file": { "chat_mode": "openai_gpt", diff --git a/main.py b/main.py index 60472cd4..2fb0353e 100644 --- a/main.py +++ b/main.py @@ -1511,6 +1511,17 @@ def zhipu_gui_create(): } data_json.append(tmp_json) + tmp_json = { + "label_text": "删除无用符号", + "label_tip": "是否开启删除无用符号功能,因为模型会有心理描述和啥特殊字符的内容,不需要的可以开启", + "data": zhipu_config["remove_useless"], + "widget_text": "启用", + "click_func": "", + "main_obj_name": "zhipu", + "index": 10 + } + data_json.append(tmp_json) + # logging.info(data_json) widgets = self.create_widgets_from_json(data_json) @@ -3081,7 +3092,8 @@ def reorganize_copywriting_config_data(copywriting_config_data): "user_info": 6, "bot_info": 7, "bot_name": 8, - "user_name": 9 + "user_name": 9, + "remove_useless": 10 } # 重组zhipu数据并写回json diff --git a/utils/gpt_model/zhipu.py b/utils/gpt_model/zhipu.py index d8599a16..aee847d5 100644 --- a/utils/gpt_model/zhipu.py +++ b/utils/gpt_model/zhipu.py @@ -24,6 +24,8 @@ def __init__(self, data): self.bot_info = data["bot_info"] self.bot_name = data["bot_name"] self.user_name = data["user_name"] + + self.remove_useless = data["remove_useless"] self.history = [] @@ -115,6 +117,22 @@ def remove_extra_backslashes(self, input_string): return cleaned_string + def remove_useless_and_contents(self, input_string): + """使用正则表达式替换括号及其内部内容为空字符串、特殊字符 + + Args: + input_string (str): 原始字符串 + + Returns: + str: 替换完后的字符串 + """ + result = re.sub(r'\(.*?\)', '', input_string) + result = re.sub(r'\(.*?\)', '', result) + result = result.replace('"', '').replace('“', '').replace('”', '').replace('\\', '') + + return result + + def get_resp(self, prompt): """请求对应接口,获取返回值 @@ -164,6 +182,9 @@ def get_resp(self, prompt): # 使用正则表达式替换多个反斜杠为一个反斜杠 resp_content = self.remove_extra_backslashes(resp_content) + if self.remove_useless: + resp_content = self.remove_useless_and_contents(resp_content) + # logging.info(f"resp_content={resp_content}") return resp_content @@ -191,7 +212,8 @@ def get_resp(self, prompt): "user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。", "bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。", "bot_name": "苏梦远", - "user_name": "陆星辰" + "user_name": "陆星辰", + "remove_useless": True } zhipu = Zhipu(data) diff --git a/webui.py b/webui.py index b13e61f7..f92de8c2 100644 --- a/webui.py +++ b/webui.py @@ -150,175 +150,179 @@ def common_textarea_handle(content): try: - config_data["platform"] = select_platform.value - config_data["room_display_id"] = input_room_display_id.value - config_data["chat_type"] = select_chat_type.value - config_data["need_lang"] = select_need_lang.value - config_data["before_prompt"] = input_before_prompt.value - config_data["after_prompt"] = input_after_prompt.value - - # 哔哩哔哩 - config_data["bilibili"]["login_type"] = select_bilibili_login_type.value - config_data["bilibili"]["cookie"] = input_bilibili_cookie.value - config_data["bilibili"]["ac_time_value"] = input_bilibili_ac_time_value.value - - # 音频播放 - config_data["play_audio"]["enable"] = switch_play_audio_enable.value - config_data["play_audio"]["out_path"] = input_play_audio_out_path.value - - # 念弹幕 - config_data["read_comment"]["enable"] = switch_read_comment_enable.value - config_data["read_comment"]["read_username_enable"] = switch_read_comment_read_username_enable.value - config_data["read_comment"]["voice_change"] = switch_read_comment_voice_change.value - config_data["read_comment"]["read_username_copywriting"] = common_textarea_handle(textarea_read_comment_read_username_copywriting.value) - - # 念用户名 - config_data["read_user_name"]["enable"] = switch_read_user_name_enable.value - config_data["read_user_name"]["voice_change"] = switch_read_user_name_voice_change.value - config_data["read_user_name"]["reply_before"] = textarea_read_user_name_reply_before.value - config_data["read_user_name"]["reply_after"] = textarea_read_user_name_reply_after.value - - # 日志 - config_data["comment_log_type"] = select_comment_log_type.value - config_data["captions"]["enable"] = switch_captions_enable.value - config_data["captions"]["file_path"] = input_captions_file_path.value - - # 本地问答 - config_data["local_qa"]["text"]["enable"] = switch_local_qa_text_enable.value - local_qa_text_type = select_local_qa_text_type.value - if local_qa_text_type == "自定义json": - config_data["local_qa"]["text"]["type"] = "json" - elif local_qa_text_type == "一问一答": - config_data["local_qa"]["text"]["type"] = "text" - config_data["local_qa"]["text"]["file_path"] = input_local_qa_text_file_path.value - config_data["local_qa"]["text"]["similarity"] = round(float(input_local_qa_text_similarity.value), 2) - config_data["local_qa"]["audio"]["enable"] = switch_local_qa_audio_enable.value - config_data["local_qa"]["audio"]["file_path"] = input_local_qa_audio_file_path.value - config_data["local_qa"]["audio"]["similarity"] = round(float(input_local_qa_audio_similarity.value), 2) - - # 过滤 - config_data["filter"]["before_must_str"] = common_textarea_handle(textarea_filter_before_must_str.value) - config_data["filter"]["after_must_str"] = common_textarea_handle(textarea_filter_after_must_str.value) - config_data["filter"]["badwords_path"] = input_filter_badwords_path.value - config_data["filter"]["bad_pinyin_path"] = input_filter_bad_pinyin_path.value - config_data["filter"]["max_len"] = int(input_filter_max_len.value) - config_data["filter"]["max_char_len"] = int(input_filter_max_char_len.value) - config_data["filter"]["comment_forget_duration"] = round(float(input_filter_comment_forget_duration.value), 2) - config_data["filter"]["comment_forget_reserve_num"] = int(input_filter_comment_forget_reserve_num.value) - config_data["filter"]["gift_forget_duration"] = round(float(input_filter_gift_forget_duration.value), 2) - config_data["filter"]["gift_forget_reserve_num"] = int(input_filter_gift_forget_reserve_num.value) - config_data["filter"]["entrance_forget_duration"] = round(float(input_filter_entrance_forget_duration.value), 2) - config_data["filter"]["entrance_forget_reserve_num"] = int(input_filter_entrance_forget_reserve_num.value) - config_data["filter"]["follow_forget_duration"] = round(float(input_filter_follow_forget_duration.value), 2) - config_data["filter"]["follow_forget_reserve_num"] = int(input_filter_follow_forget_reserve_num.value) - config_data["filter"]["talk_forget_duration"] = round(float(input_filter_talk_forget_duration.value), 2) - config_data["filter"]["talk_forget_reserve_num"] = int(input_filter_talk_forget_reserve_num.value) - config_data["filter"]["schedule_forget_duration"] = round(float(input_filter_schedule_forget_duration.value), 2) - config_data["filter"]["schedule_forget_reserve_num"] = int(input_filter_schedule_forget_reserve_num.value) - - # 答谢 - config_data["thanks"]["entrance_enable"] = switch_thanks_entrance_enable.value - config_data["thanks"]["entrance_copy"] = input_thanks_entrance_copy.value - config_data["thanks"]["gift_enable"] = switch_thanks_gift_enable.value - config_data["thanks"]["gift_copy"] = input_thanks_gift_copy.value - config_data["thanks"]["lowest_price"] = round(float(input_thanks_lowest_price.value), 2) - config_data["thanks"]["follow_enable"] = switch_thanks_follow_enable.value - config_data["thanks"]["follow_copy"] = input_thanks_follow_copy.value - - # 音频随机变速 - config_data["audio_random_speed"]["normal"]["enable"] = switch_audio_random_speed_normal_enable.value - config_data["audio_random_speed"]["normal"]["speed_min"] = round(float(input_audio_random_speed_normal_speed_min.value), 2) - config_data["audio_random_speed"]["normal"]["speed_max"] = round(float(input_audio_random_speed_normal_speed_max.value), 2) - config_data["audio_random_speed"]["copywriting"]["enable"] = switch_audio_random_speed_copywriting_enable.value - config_data["audio_random_speed"]["copywriting"]["speed_min"] = round(float(input_audio_random_speed_copywriting_speed_min.value), 2) - config_data["audio_random_speed"]["copywriting"]["speed_max"] = round(float(input_audio_random_speed_copywriting_speed_max.value), 2) - - # Live2D - config_data["live2d"]["enable"] = switch_live2d_enable.value - config_data["live2d"]["port"] = int(input_live2d_port.value) - - # 定时任务 - tmp_arr = [] - # logging.info(schedule_var) - for index in range(len(schedule_var) // 3): - tmp_json = { - "enable": False, - "time": 60, - "copy": [] - } - tmp_json["enable"] = schedule_var[str(3 * index)].value - tmp_json["time"] = round(float(schedule_var[str(3 * index + 1)].value), 1) - tmp_json["copy"] = common_textarea_handle(schedule_var[str(3 * index + 2)].value) - - tmp_arr.append(tmp_json) - # logging.info(tmp_arr) - config_data["schedule"] = tmp_arr - - # SD - config_data["sd"]["enable"] = switch_sd_enable.value - config_data["sd"]["prompt_llm"]["type"] = select_sd_prompt_llm_type.value - config_data["sd"]["prompt_llm"]["before_prompt"] = input_sd_prompt_llm_before_prompt.value - config_data["sd"]["prompt_llm"]["after_prompt"] = input_sd_prompt_llm_after_prompt.value - config_data["sd"]["trigger"] = input_sd_trigger.value - config_data["sd"]["ip"] = input_sd_ip.value - sd_port = input_sd_port.value - config_data["sd"]["port"] = int(sd_port) - config_data["sd"]["negative_prompt"] = input_sd_negative_prompt.value - config_data["sd"]["seed"] = float(input_sd_seed.value) - # 获取多行文本输入框的内容 - config_data["sd"]["styles"] = common_textarea_handle(textarea_sd_styles.value) - config_data["sd"]["cfg_scale"] = int(input_sd_cfg_scale.value) - config_data["sd"]["steps"] = int(input_sd_steps.value) - config_data["sd"]["hr_resize_x"] = int(input_sd_hr_resize_x.value) - config_data["sd"]["hr_resize_y"] = int(input_sd_hr_resize_y.value) - config_data["sd"]["enable_hr"] = switch_sd_enable_hr.value - config_data["sd"]["hr_scale"] = int(input_sd_hr_scale.value) - config_data["sd"]["hr_second_pass_steps"] = int(input_sd_hr_second_pass_steps.value) - config_data["sd"]["denoising_strength"] = round(float(input_sd_denoising_strength.value), 1) - - # 动态文案 - config_data["trends_copywriting"]["enable"] = switch_trends_copywriting_enable.value - config_data["trends_copywriting"]["random_play"] = switch_trends_copywriting_random_play.value - config_data["trends_copywriting"]["play_interval"] = int(input_trends_copywriting_play_interval.value) - tmp_arr = [] - for index in range(len(trends_copywriting_copywriting_var) // 3): - tmp_json = { - "folder_path": "", - "prompt_change_enable": False, - "prompt_change_content": "" - } - tmp_json["folder_path"] = trends_copywriting_copywriting_var[str(3 * index)].value - tmp_json["prompt_change_enable"] = trends_copywriting_copywriting_var[str(3 * index + 1)].value - tmp_json["prompt_change_content"] = trends_copywriting_copywriting_var[str(3 * index + 2)].value - - tmp_arr.append(tmp_json) - # logging.info(tmp_arr) - config_data["trends_copywriting"]["copywriting"] = tmp_arr - - # 数据库 - config_data["database"]["path"] = input_database_path.value - config_data["database"]["comment_enable"] = switch_database_comment_enable.value - config_data["database"]["entrance_enable"] = switch_database_entrance_enable.value - config_data["database"]["gift_enable"] = switch_database_gift_enable.value - - # 按键映射 - config_data["key_mapping"]["enable"] = switch_key_mapping_enable.value - config_data["key_mapping"]["start_cmd"] = input_key_mapping_start_cmd.value - tmp_arr = [] - # logging.info(key_mapping_config_var) - for index in range(len(key_mapping_config_var) // 3): - tmp_json = { - "keywords": [], - "keys": [], - "similarity": 1 - } - tmp_json["keywords"] = common_textarea_handle(key_mapping_config_var[str(3 * index)].value) - tmp_json["keys"] = common_textarea_handle(key_mapping_config_var[str(3 * index + 1)].value) - tmp_json["similarity"] = key_mapping_config_var[str(3 * index + 2)].value - - tmp_arr.append(tmp_json) - # logging.info(tmp_arr) - config_data["key_mapping"]["config"] = tmp_arr + """ + 通用配置 + """ + if True: + config_data["platform"] = select_platform.value + config_data["room_display_id"] = input_room_display_id.value + config_data["chat_type"] = select_chat_type.value + config_data["need_lang"] = select_need_lang.value + config_data["before_prompt"] = input_before_prompt.value + config_data["after_prompt"] = input_after_prompt.value + + # 哔哩哔哩 + config_data["bilibili"]["login_type"] = select_bilibili_login_type.value + config_data["bilibili"]["cookie"] = input_bilibili_cookie.value + config_data["bilibili"]["ac_time_value"] = input_bilibili_ac_time_value.value + + # 音频播放 + config_data["play_audio"]["enable"] = switch_play_audio_enable.value + config_data["play_audio"]["out_path"] = input_play_audio_out_path.value + + # 念弹幕 + config_data["read_comment"]["enable"] = switch_read_comment_enable.value + config_data["read_comment"]["read_username_enable"] = switch_read_comment_read_username_enable.value + config_data["read_comment"]["voice_change"] = switch_read_comment_voice_change.value + config_data["read_comment"]["read_username_copywriting"] = common_textarea_handle(textarea_read_comment_read_username_copywriting.value) + + # 念用户名 + config_data["read_user_name"]["enable"] = switch_read_user_name_enable.value + config_data["read_user_name"]["voice_change"] = switch_read_user_name_voice_change.value + config_data["read_user_name"]["reply_before"] = textarea_read_user_name_reply_before.value + config_data["read_user_name"]["reply_after"] = textarea_read_user_name_reply_after.value + + # 日志 + config_data["comment_log_type"] = select_comment_log_type.value + config_data["captions"]["enable"] = switch_captions_enable.value + config_data["captions"]["file_path"] = input_captions_file_path.value + + # 本地问答 + config_data["local_qa"]["text"]["enable"] = switch_local_qa_text_enable.value + local_qa_text_type = select_local_qa_text_type.value + if local_qa_text_type == "自定义json": + config_data["local_qa"]["text"]["type"] = "json" + elif local_qa_text_type == "一问一答": + config_data["local_qa"]["text"]["type"] = "text" + config_data["local_qa"]["text"]["file_path"] = input_local_qa_text_file_path.value + config_data["local_qa"]["text"]["similarity"] = round(float(input_local_qa_text_similarity.value), 2) + config_data["local_qa"]["audio"]["enable"] = switch_local_qa_audio_enable.value + config_data["local_qa"]["audio"]["file_path"] = input_local_qa_audio_file_path.value + config_data["local_qa"]["audio"]["similarity"] = round(float(input_local_qa_audio_similarity.value), 2) + + # 过滤 + config_data["filter"]["before_must_str"] = common_textarea_handle(textarea_filter_before_must_str.value) + config_data["filter"]["after_must_str"] = common_textarea_handle(textarea_filter_after_must_str.value) + config_data["filter"]["badwords_path"] = input_filter_badwords_path.value + config_data["filter"]["bad_pinyin_path"] = input_filter_bad_pinyin_path.value + config_data["filter"]["max_len"] = int(input_filter_max_len.value) + config_data["filter"]["max_char_len"] = int(input_filter_max_char_len.value) + config_data["filter"]["comment_forget_duration"] = round(float(input_filter_comment_forget_duration.value), 2) + config_data["filter"]["comment_forget_reserve_num"] = int(input_filter_comment_forget_reserve_num.value) + config_data["filter"]["gift_forget_duration"] = round(float(input_filter_gift_forget_duration.value), 2) + config_data["filter"]["gift_forget_reserve_num"] = int(input_filter_gift_forget_reserve_num.value) + config_data["filter"]["entrance_forget_duration"] = round(float(input_filter_entrance_forget_duration.value), 2) + config_data["filter"]["entrance_forget_reserve_num"] = int(input_filter_entrance_forget_reserve_num.value) + config_data["filter"]["follow_forget_duration"] = round(float(input_filter_follow_forget_duration.value), 2) + config_data["filter"]["follow_forget_reserve_num"] = int(input_filter_follow_forget_reserve_num.value) + config_data["filter"]["talk_forget_duration"] = round(float(input_filter_talk_forget_duration.value), 2) + config_data["filter"]["talk_forget_reserve_num"] = int(input_filter_talk_forget_reserve_num.value) + config_data["filter"]["schedule_forget_duration"] = round(float(input_filter_schedule_forget_duration.value), 2) + config_data["filter"]["schedule_forget_reserve_num"] = int(input_filter_schedule_forget_reserve_num.value) + + # 答谢 + config_data["thanks"]["entrance_enable"] = switch_thanks_entrance_enable.value + config_data["thanks"]["entrance_copy"] = input_thanks_entrance_copy.value + config_data["thanks"]["gift_enable"] = switch_thanks_gift_enable.value + config_data["thanks"]["gift_copy"] = input_thanks_gift_copy.value + config_data["thanks"]["lowest_price"] = round(float(input_thanks_lowest_price.value), 2) + config_data["thanks"]["follow_enable"] = switch_thanks_follow_enable.value + config_data["thanks"]["follow_copy"] = input_thanks_follow_copy.value + + # 音频随机变速 + config_data["audio_random_speed"]["normal"]["enable"] = switch_audio_random_speed_normal_enable.value + config_data["audio_random_speed"]["normal"]["speed_min"] = round(float(input_audio_random_speed_normal_speed_min.value), 2) + config_data["audio_random_speed"]["normal"]["speed_max"] = round(float(input_audio_random_speed_normal_speed_max.value), 2) + config_data["audio_random_speed"]["copywriting"]["enable"] = switch_audio_random_speed_copywriting_enable.value + config_data["audio_random_speed"]["copywriting"]["speed_min"] = round(float(input_audio_random_speed_copywriting_speed_min.value), 2) + config_data["audio_random_speed"]["copywriting"]["speed_max"] = round(float(input_audio_random_speed_copywriting_speed_max.value), 2) + + # Live2D + config_data["live2d"]["enable"] = switch_live2d_enable.value + config_data["live2d"]["port"] = int(input_live2d_port.value) + + # 定时任务 + tmp_arr = [] + # logging.info(schedule_var) + for index in range(len(schedule_var) // 3): + tmp_json = { + "enable": False, + "time": 60, + "copy": [] + } + tmp_json["enable"] = schedule_var[str(3 * index)].value + tmp_json["time"] = round(float(schedule_var[str(3 * index + 1)].value), 1) + tmp_json["copy"] = common_textarea_handle(schedule_var[str(3 * index + 2)].value) + + tmp_arr.append(tmp_json) + # logging.info(tmp_arr) + config_data["schedule"] = tmp_arr + + # SD + config_data["sd"]["enable"] = switch_sd_enable.value + config_data["sd"]["prompt_llm"]["type"] = select_sd_prompt_llm_type.value + config_data["sd"]["prompt_llm"]["before_prompt"] = input_sd_prompt_llm_before_prompt.value + config_data["sd"]["prompt_llm"]["after_prompt"] = input_sd_prompt_llm_after_prompt.value + config_data["sd"]["trigger"] = input_sd_trigger.value + config_data["sd"]["ip"] = input_sd_ip.value + sd_port = input_sd_port.value + config_data["sd"]["port"] = int(sd_port) + config_data["sd"]["negative_prompt"] = input_sd_negative_prompt.value + config_data["sd"]["seed"] = float(input_sd_seed.value) + # 获取多行文本输入框的内容 + config_data["sd"]["styles"] = common_textarea_handle(textarea_sd_styles.value) + config_data["sd"]["cfg_scale"] = int(input_sd_cfg_scale.value) + config_data["sd"]["steps"] = int(input_sd_steps.value) + config_data["sd"]["hr_resize_x"] = int(input_sd_hr_resize_x.value) + config_data["sd"]["hr_resize_y"] = int(input_sd_hr_resize_y.value) + config_data["sd"]["enable_hr"] = switch_sd_enable_hr.value + config_data["sd"]["hr_scale"] = int(input_sd_hr_scale.value) + config_data["sd"]["hr_second_pass_steps"] = int(input_sd_hr_second_pass_steps.value) + config_data["sd"]["denoising_strength"] = round(float(input_sd_denoising_strength.value), 1) + + # 动态文案 + config_data["trends_copywriting"]["enable"] = switch_trends_copywriting_enable.value + config_data["trends_copywriting"]["random_play"] = switch_trends_copywriting_random_play.value + config_data["trends_copywriting"]["play_interval"] = int(input_trends_copywriting_play_interval.value) + tmp_arr = [] + for index in range(len(trends_copywriting_copywriting_var) // 3): + tmp_json = { + "folder_path": "", + "prompt_change_enable": False, + "prompt_change_content": "" + } + tmp_json["folder_path"] = trends_copywriting_copywriting_var[str(3 * index)].value + tmp_json["prompt_change_enable"] = trends_copywriting_copywriting_var[str(3 * index + 1)].value + tmp_json["prompt_change_content"] = trends_copywriting_copywriting_var[str(3 * index + 2)].value + + tmp_arr.append(tmp_json) + # logging.info(tmp_arr) + config_data["trends_copywriting"]["copywriting"] = tmp_arr + + # 数据库 + config_data["database"]["path"] = input_database_path.value + config_data["database"]["comment_enable"] = switch_database_comment_enable.value + config_data["database"]["entrance_enable"] = switch_database_entrance_enable.value + config_data["database"]["gift_enable"] = switch_database_gift_enable.value + + # 按键映射 + config_data["key_mapping"]["enable"] = switch_key_mapping_enable.value + config_data["key_mapping"]["start_cmd"] = input_key_mapping_start_cmd.value + tmp_arr = [] + # logging.info(key_mapping_config_var) + for index in range(len(key_mapping_config_var) // 3): + tmp_json = { + "keywords": [], + "keys": [], + "similarity": 1 + } + tmp_json["keywords"] = common_textarea_handle(key_mapping_config_var[str(3 * index)].value) + tmp_json["keys"] = common_textarea_handle(key_mapping_config_var[str(3 * index + 1)].value) + tmp_json["similarity"] = key_mapping_config_var[str(3 * index + 2)].value + + tmp_arr.append(tmp_json) + # logging.info(tmp_arr) + config_data["key_mapping"]["config"] = tmp_arr """ LLM @@ -391,6 +395,7 @@ def common_textarea_handle(content): config_data["zhipu"]["temperature"] = input_zhipu_temperature.value config_data["zhipu"]["history_enable"] = switch_zhipu_history_enable.value config_data["zhipu"]["history_max_len"] = input_zhipu_history_max_len.value + config_data["zhipu"]["remove_useless"] = switch_zhipu_remove_useless.value config_data["bard"]["token"] = input_bard_token.value @@ -988,6 +993,8 @@ def textarea_data_change(data): input_zhipu_bot_name.style("width:400px") input_zhipu_user_name = ui.input(label='用户名称', placeholder='用户名称,默认值为用户,当使用characterglm时需要配置', value=config.get("zhipu", "user_name")) input_zhipu_user_name.style("width:400px") + with ui.grid(columns=2): + switch_zhipu_remove_useless = ui.switch('删除中文括号', value=config.get("zhipu", "remove_useless")) with ui.card().style("margin:10px 0px"): ui.label("Bard") with ui.grid(columns=2):