diff --git a/config.json b/config.json index 3d1ad9aa..63156e67 100644 --- a/config.json +++ b/config.json @@ -363,9 +363,17 @@ "token": "" }, "yiyan": { - "api_ip_port": "http://localhost:3000", - "type": "web", - "cookie": "" + "type": "api", + "web": { + "api_ip_port": "http://127.0.0.1:3000", + "cookie": "" + }, + "api": { + "api_key": "", + "secret_key": "" + }, + "history_enable": true, + "history_max_len": 300 }, "tongyi": { "type": "web", diff --git a/config.json.bak b/config.json.bak index 3d1ad9aa..63156e67 100644 --- a/config.json.bak +++ b/config.json.bak @@ -363,9 +363,17 @@ "token": "" }, "yiyan": { - "api_ip_port": "http://localhost:3000", - "type": "web", - "cookie": "" + "type": "api", + "web": { + "api_ip_port": "http://127.0.0.1:3000", + "cookie": "" + }, + "api": { + "api_key": "", + "secret_key": "" + }, + "history_enable": true, + "history_max_len": 300 }, "tongyi": { "type": "web", diff --git a/docs/AI Vtuber.xmind b/docs/AI Vtuber.xmind index a3ef485c..9488c99a 100644 Binary files a/docs/AI Vtuber.xmind and b/docs/AI Vtuber.xmind differ diff --git a/docs/xmind.png b/docs/xmind.png index 80e75bbd..09843ea6 100644 Binary files a/docs/xmind.png and b/docs/xmind.png differ diff --git a/tests/test_yiyan/api.py b/tests/test_yiyan/api.py new file mode 100644 index 00000000..9be7e475 --- /dev/null +++ b/tests/test_yiyan/api.py @@ -0,0 +1,160 @@ +import json, logging +import requests, time +from requests.exceptions import ConnectionError, RequestException + +# from utils.common import Common +# from utils.logger import Configure_logger + +# 原计划对接:https://github.com/zhuweiyou/yiyan-api +class Yiyan: + def __init__(self, data): + # self.common = Common() + # # 日志文件路径 + # file_path = "./log/log-" + self.common.get_bj_time(1) + ".txt" + # Configure_logger(file_path) + + self.config_data = data + self.type = data["type"] + + self.history = [] + + + def get_access_token(self): + """ + 使用 API Key,Secret Key 获取access_token,替换下列示例中的应用API Key、应用Secret Key + """ + + url = f'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={self.config_data["api"]["api_key"]}&client_secret={self.config_data["api"]["secret_key"]}' + + payload = json.dumps("") + headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + + response = requests.request("POST", url, headers=headers, data=payload) + return response.json().get("access_token") + + + def get_resp(self, prompt): + """请求对应接口,获取返回值 + + Args: + prompt (str): 你的提问 + + Returns: + str: 返回的文本回答 + """ + try: + if self.type == "web": + try: + data_json = { + "cookie": self.config_data["web"]["cookie"], + "prompt": prompt + } + + # logging.debug(data_json) + + url = self.config_data["web"]["api_ip_port"] + "/headless" + + response = requests.post(url=url, data=data_json) + response.raise_for_status() # 检查响应的状态码 + + result = response.content + ret = json.loads(result) + + logging.debug(ret) + + resp_content = ret['text'].replace('\n', '').replace('\\n', '') + + # 启用历史就给我记住! + if self.config_data["history_enable"]: + while True: + # 获取嵌套列表中所有字符串的字符数 + total_chars = sum(len(string) for sublist in self.history for string in sublist) + # 如果大于限定最大历史数,就剔除第一个元素 + if total_chars > self.config_data["history_max_len"]: + self.history.pop(0) + else: + self.history.append({"role": "user", "content": prompt}) + self.history.append({"role": "assistant", "content": resp_content}) + break + + return resp_content + except ConnectionError as ce: + # 处理连接问题异常 + logging.error(f"请检查你是否启动了服务端或配置是否匹配,连接异常:{ce}") + + except RequestException as re: + # 处理其他请求异常 + logging.error(f"请求异常:{re}") + except Exception as e: + logging.error(e) + else: + url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions?access_token=" + self.get_access_token() + + data_json = { + "messages": self.history + [{"role": "user", "content": prompt}] + } + + payload = json.dumps(data_json) + + headers = { + 'Content-Type': 'application/json' + } + + response = requests.request("POST", url, headers=headers, data=payload) + + logging.info(payload) + logging.info(response.text) + + resp_content = json.loads(response.text)["result"] + + # 启用历史就给我记住! + if self.config_data["history_enable"]: + while True: + # 获取嵌套列表中所有字符串的字符数 + total_chars = sum(len(string) for sublist in self.history for string in sublist) + # 如果大于限定最大历史数,就剔除第一个元素 + if total_chars > self.config_data["history_max_len"]: + self.history.pop(0) + else: + self.history.append({"role": "user", "content": prompt}) + self.history.append({"role": "assistant", "content": resp_content}) + break + + return resp_content + except Exception as e: + logging.error(e) + + return None + + +if __name__ == '__main__': + # 配置日志输出格式 + logging.basicConfig( + level=logging.DEBUG, # 设置日志级别,可以根据需求调整 + format="%(asctime)s [%(levelname)s] %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", + ) + + data = { + "type": 'api', + "web": { + "api_ip_port": "http://127.0.0.1:3000", + "cookie": '' + }, + "api": { + "api_key": "", + "secret_key": "" + }, + "history_enable": True, + "history_max_len": 300 + } + yiyan = Yiyan(data) + + + logging.info(yiyan.get_resp("你可以扮演猫娘吗,每句话后面加个喵")) + time.sleep(1) + logging.info(yiyan.get_resp("早上好")) + \ No newline at end of file diff --git a/tests/test_yiyan/web.py b/tests/test_yiyan/web.py deleted file mode 100644 index d3ef5a6c..00000000 --- a/tests/test_yiyan/web.py +++ /dev/null @@ -1,83 +0,0 @@ -import json, logging -import requests -from requests.exceptions import ConnectionError, RequestException - -# from utils.common import Common -# from utils.logger import Configure_logger - -# 原计划对接:https://github.com/zhuweiyou/yiyan-api -# 出现超时请求的错误,待推进 -class Yiyan: - def __init__(self, data): - # self.common = Common() - # 日志文件路径 - # file_path = "./log/log-" + self.common.get_bj_time(1) + ".txt" - # Configure_logger(file_path) - - self.api_ip_port = data["api_ip_port"] - self.cookie = data["cookie"] - self.type = data["type"] - - - def get_resp(self, prompt): - """请求对应接口,获取返回值 - - Args: - prompt (str): 你的提问 - - Returns: - str: 返回的文本回答 - """ - try: - data_json = { - "cookie": self.cookie, - "prompt": prompt - } - - # logging.debug(data_json) - - url = self.api_ip_port + "/headless" - - response = requests.post(url=url, data=data_json) - response.raise_for_status() # 检查响应的状态码 - - result = response.content - ret = json.loads(result) - - logging.debug(ret) - - resp_content = ret['text'].replace('\n', '').replace('\\n', '') - - return resp_content - except ConnectionError as ce: - # 处理连接问题异常 - logging.error(f"请检查你是否启动了服务端或配置是否匹配,连接异常:{ce}") - - except RequestException as re: - # 处理其他请求异常 - logging.error(f"请求异常:{re}") - except Exception as e: - logging.error(e) - - return None - - -if __name__ == '__main__': - # 配置日志输出格式 - logging.basicConfig( - level=logging.DEBUG, # 设置日志级别,可以根据需求调整 - format="%(asctime)s [%(levelname)s] %(message)s", - datefmt="%Y-%m-%d %H:%M:%S", - ) - - data = { - "api_ip_port": "http://localhost:3000", - "cookie": 'BIDUPSID=A668F884A60F8775B4F5319BB5AD816B; PSTM=1686378956; BAIDUID=8051FCC40FE4D6347C3AABB45F813283:FG=1; H_WISE_SIDS=216853_213352_214792_110085_244720_261710_236312_256419_265881_266360_265615_267074_259031_268593_266187_259642_269778_269832_269904_267066_256739_270460_270535_270516_270547_271170_263618_271321_265034_271272_266028_270102_271560_271869_271674_269858_271812_267804_271255_234296_234207_272223_272284_272458_253022_272741_272841_260335_269297_267596_273061_267560_273161_273118_273136_273240_273301_273400_270055_271146_273671_273704_264170_270186_270142_274080_273932_273965_274141_274177_269610_274207_273917_273786_273043_273598_263750_272319_272560_274425_274422_272332_197096_274767_274760_274843_274854_274857_274847_274819_270158_274870_273982_275069_272801_267806_267548_273923_275167_275214_275147_275237_274897_274785_271157_275617_275773_273492; H_WISE_SIDS_BFESS=216853_213352_214792_110085_244720_261710_236312_256419_265881_266360_265615_267074_259031_268593_266187_259642_269778_269832_269904_267066_256739_270460_270535_270516_270547_271170_263618_271321_265034_271272_266028_270102_271560_271869_271674_269858_271812_267804_271255_234296_234207_272223_272284_272458_253022_272741_272841_260335_269297_267596_273061_267560_273161_273118_273136_273240_273301_273400_270055_271146_273671_273704_264170_270186_270142_274080_273932_273965_274141_274177_269610_274207_273917_273786_273043_273598_263750_272319_272560_274425_274422_272332_197096_274767_274760_274843_274854_274857_274847_274819_270158_274870_273982_275069_272801_267806_267548_273923_275167_275214_275147_275237_274897_274785_271157_275617_275773_273492; newlogin=1; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; H_PS_PSSID=; BA_HECTOR=alalah8g04a501240k24al071ig09i91p; delPer=0; PSINO=5; ZFY=CuxQF:BDwJXcSl2ykZnlvdUMlBPXnOnvQ4Ak6QZqryD0:C; BAIDUID_BFESS=8051FCC40FE4D6347C3AABB45F813283:FG=1; Hm_lvt_01e907653ac089993ee83ed00ef9c2f3=1692541101,1693483352,1693709742,1694508619; __bid_n=188cd9d38714368c1980bd; BDUSS=RhSVAwM2NlSFk0UGludGU2dWl-VC1Vb0FFd0NXUHJ2UVZSalhNQTV4Ump0U2RsSVFBQUFBJCQAAAAAAAAAAAEAAAAvH~80z8S48bb7UEMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGMoAGVjKABlb0; BDUSS_BFESS=RhSVAwM2NlSFk0UGludGU2dWl-VC1Vb0FFd0NXUHJ2UVZSalhNQTV4Ump0U2RsSVFBQUFBJCQAAAAAAAAAAAEAAAAvH~80z8S48bb7UEMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGMoAGVjKABlb0; XFI=ac0eb9a0-514a-11ee-8d90-dbcda17c31a9; Hm_lpvt_01e907653ac089993ee83ed00ef9c2f3=1694509165; ab_sr=1.0.1_NDBiOGYxZGJhOTM5NmZlYjYxYjZlZjUzYzdmZjRkNGZhNGEyYzk5YmI1MGU1ZmI2ZDRlYWQwZTgwYjM3N2I1ZmI0MWU1YzM1N2IxYTdhMjdiNWI5ZTY1OTA2NDA0M2Q1YThkZjRkZWExMTM5MzdjMjU4M2I0NzA5YzUyNGU3ZmI4ODEyMGJmNWVkMDcyNGNlZTViNWUxM2FmYWQ4NThhNDVmNDJjYjI1ZjRlOWExZmFkZDljYzI1NzEyZTU2MDI1; XFCS=34CC02EB9FA200485B99840D5B4EAB820D85D82ADAAFB79262DDC7BD2BB0BAE4; XFT=CxTPRAPWDer6bnpF5VhnliaRBOx+vtCDR5ZO6CDCPzk=; RT="z=1&dm=baidu.com&si=61c46ce5-0a6d-4ff8-bd8d-6fddd3e9d2e3&ss=lmg2ohen&sl=c&tt=ge4&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=bwoy"', - "type": 'web' - } - yiyan = Yiyan(data) - - - logging.info(yiyan.get_resp("你可以扮演猫娘吗,每句话后面加个喵")) - logging.info(yiyan.get_resp("早上好")) - \ No newline at end of file diff --git a/utils/gpt_model/yiyan.py b/utils/gpt_model/yiyan.py index 9f78db25..fc989a37 100644 --- a/utils/gpt_model/yiyan.py +++ b/utils/gpt_model/yiyan.py @@ -1,5 +1,5 @@ import json, logging -import requests +import requests, time from requests.exceptions import ConnectionError, RequestException from utils.common import Common @@ -13,10 +13,28 @@ def __init__(self, data): file_path = "./log/log-" + self.common.get_bj_time(1) + ".txt" Configure_logger(file_path) - self.api_ip_port = data["api_ip_port"] - self.cookie = data["cookie"] + self.config_data = data self.type = data["type"] + self.history = [] + + + def get_access_token(self): + """ + 使用 API Key,Secret Key 获取access_token,替换下列示例中的应用API Key、应用Secret Key + """ + + url = f'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={self.config_data["api"]["api_key"]}&client_secret={self.config_data["api"]["secret_key"]}' + + payload = json.dumps("") + headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + + response = requests.request("POST", url, headers=headers, data=payload) + return response.json().get("access_token") + def get_resp(self, prompt): """请求对应接口,获取返回值 @@ -28,36 +46,87 @@ def get_resp(self, prompt): str: 返回的文本回答 """ try: - data_json = { - "cookie": self.cookie, - "prompt": prompt - } - - # logging.debug(data_json) - - url = self.api_ip_port + "/headless" - - response = requests.post(url=url, data=data_json) - response.raise_for_status() # 检查响应的状态码 - - result = response.content - ret = json.loads(result) - - logging.debug(ret) - - resp_content = ret['text'].replace('\n', '').replace('\\n', '') - - return resp_content - except ConnectionError as ce: - # 处理连接问题异常 - logging.error(f"请检查你是否启动了服务端或配置是否匹配,连接异常:{ce}") - - except RequestException as re: - # 处理其他请求异常 - logging.error(f"请求异常:{re}") + if self.type == "web": + try: + data_json = { + "cookie": self.config_data["web"]["cookie"], + "prompt": prompt + } + + # logging.debug(data_json) + + url = self.config_data["web"]["api_ip_port"] + "/headless" + + response = requests.post(url=url, data=data_json) + response.raise_for_status() # 检查响应的状态码 + + result = response.content + ret = json.loads(result) + + logging.debug(ret) + + resp_content = ret['text'].replace('\n', '').replace('\\n', '') + + # 启用历史就给我记住! + if self.config_data["history_enable"]: + while True: + # 获取嵌套列表中所有字符串的字符数 + total_chars = sum(len(string) for sublist in self.history for string in sublist) + # 如果大于限定最大历史数,就剔除第一个元素 + if total_chars > self.config_data["history_max_len"]: + self.history.pop(0) + else: + self.history.append({"role": "user", "content": prompt}) + self.history.append({"role": "assistant", "content": resp_content}) + break + + return resp_content + except ConnectionError as ce: + # 处理连接问题异常 + logging.error(f"请检查你是否启动了服务端或配置是否匹配,连接异常:{ce}") + + except RequestException as re: + # 处理其他请求异常 + logging.error(f"请求异常:{re}") + except Exception as e: + logging.error(e) + else: + url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions?access_token=" + self.get_access_token() + + data_json = { + "messages": self.history + [{"role": "user", "content": prompt}] + } + + payload = json.dumps(data_json) + + headers = { + 'Content-Type': 'application/json' + } + + response = requests.request("POST", url, headers=headers, data=payload) + + logging.info(payload) + logging.info(response.text) + + resp_content = json.loads(response.text)["result"] + + # 启用历史就给我记住! + if self.config_data["history_enable"]: + while True: + # 获取嵌套列表中所有字符串的字符数 + total_chars = sum(len(string) for sublist in self.history for string in sublist) + # 如果大于限定最大历史数,就剔除第一个元素 + if total_chars > self.config_data["history_max_len"]: + self.history.pop(0) + else: + self.history.append({"role": "user", "content": prompt}) + self.history.append({"role": "assistant", "content": resp_content}) + break + + return resp_content except Exception as e: logging.error(e) - + return None @@ -70,13 +139,22 @@ def get_resp(self, prompt): ) data = { - "api_ip_port": "http://localhost:3000", - "cookie": 'BIDUPSID=A668F884A60F8775B4F5319BB5AD816B; PSTM=1686378956; BAIDUID=8051FCC40FE4D6347C3AABB45F813283:FG=1; H_WISE_SIDS=216853_213352_214792_110085_244720_261710_236312_256419_265881_266360_265615_267074_259031_268593_266187_259642_269778_269832_269904_267066_256739_270460_270535_270516_270547_271170_263618_271321_265034_271272_266028_270102_271560_271869_271674_269858_271812_267804_271255_234296_234207_272223_272284_272458_253022_272741_272841_260335_269297_267596_273061_267560_273161_273118_273136_273240_273301_273400_270055_271146_273671_273704_264170_270186_270142_274080_273932_273965_274141_274177_269610_274207_273917_273786_273043_273598_263750_272319_272560_274425_274422_272332_197096_274767_274760_274843_274854_274857_274847_274819_270158_274870_273982_275069_272801_267806_267548_273923_275167_275214_275147_275237_274897_274785_271157_275617_275773_273492; H_WISE_SIDS_BFESS=216853_213352_214792_110085_244720_261710_236312_256419_265881_266360_265615_267074_259031_268593_266187_259642_269778_269832_269904_267066_256739_270460_270535_270516_270547_271170_263618_271321_265034_271272_266028_270102_271560_271869_271674_269858_271812_267804_271255_234296_234207_272223_272284_272458_253022_272741_272841_260335_269297_267596_273061_267560_273161_273118_273136_273240_273301_273400_270055_271146_273671_273704_264170_270186_270142_274080_273932_273965_274141_274177_269610_274207_273917_273786_273043_273598_263750_272319_272560_274425_274422_272332_197096_274767_274760_274843_274854_274857_274847_274819_270158_274870_273982_275069_272801_267806_267548_273923_275167_275214_275147_275237_274897_274785_271157_275617_275773_273492; newlogin=1; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; H_PS_PSSID=; BA_HECTOR=alalah8g04a501240k24al071ig09i91p; delPer=0; PSINO=5; ZFY=CuxQF:BDwJXcSl2ykZnlvdUMlBPXnOnvQ4Ak6QZqryD0:C; BAIDUID_BFESS=8051FCC40FE4D6347C3AABB45F813283:FG=1; Hm_lvt_01e907653ac089993ee83ed00ef9c2f3=1692541101,1693483352,1693709742,1694508619; __bid_n=188cd9d38714368c1980bd; BDUSS=RhSVAwM2NlSFk0UGludGU2dWl-VC1Vb0FFd0NXUHJ2UVZSalhNQTV4Ump0U2RsSVFBQUFBJCQAAAAAAAAAAAEAAAAvH~80z8S48bb7UEMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGMoAGVjKABlb0; BDUSS_BFESS=RhSVAwM2NlSFk0UGludGU2dWl-VC1Vb0FFd0NXUHJ2UVZSalhNQTV4Ump0U2RsSVFBQUFBJCQAAAAAAAAAAAEAAAAvH~80z8S48bb7UEMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGMoAGVjKABlb0; XFI=ac0eb9a0-514a-11ee-8d90-dbcda17c31a9; Hm_lpvt_01e907653ac089993ee83ed00ef9c2f3=1694509165; ab_sr=1.0.1_NDBiOGYxZGJhOTM5NmZlYjYxYjZlZjUzYzdmZjRkNGZhNGEyYzk5YmI1MGU1ZmI2ZDRlYWQwZTgwYjM3N2I1ZmI0MWU1YzM1N2IxYTdhMjdiNWI5ZTY1OTA2NDA0M2Q1YThkZjRkZWExMTM5MzdjMjU4M2I0NzA5YzUyNGU3ZmI4ODEyMGJmNWVkMDcyNGNlZTViNWUxM2FmYWQ4NThhNDVmNDJjYjI1ZjRlOWExZmFkZDljYzI1NzEyZTU2MDI1; XFCS=34CC02EB9FA200485B99840D5B4EAB820D85D82ADAAFB79262DDC7BD2BB0BAE4; XFT=CxTPRAPWDer6bnpF5VhnliaRBOx+vtCDR5ZO6CDCPzk=; RT="z=1&dm=baidu.com&si=61c46ce5-0a6d-4ff8-bd8d-6fddd3e9d2e3&ss=lmg2ohen&sl=c&tt=ge4&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=bwoy"', - "type": 'web' + "type": 'api', + "web": { + "api_ip_port": "http://127.0.0.1:3000", + "cookie": '' + }, + "api": { + "api_key": "", + "secret_key": "" + }, + "history_enable": True, + "history_max_len": 300 } yiyan = Yiyan(data) logging.info(yiyan.get_resp("你可以扮演猫娘吗,每句话后面加个喵")) + time.sleep(1) logging.info(yiyan.get_resp("早上好")) \ No newline at end of file diff --git a/webui.py b/webui.py index 1a73474c..ba908c6c 100644 --- a/webui.py +++ b/webui.py @@ -564,9 +564,13 @@ def common_textarea_handle(content): config_data["bard"]["token"] = input_bard_token.value - config_data["yiyan"]["api_ip_port"] = input_yiyan_api_ip_port.value config_data["yiyan"]["type"] = select_yiyan_type.value - config_data["yiyan"]["cookie"] = input_yiyan_cookie.value + config_data["yiyan"]["history_enable"] = switch_yiyan_history_enable.value + config_data["yiyan"]["history_max_len"] = int(input_yiyan_history_max_len.value) + config_data["yiyan"]["api"]["api_key"] = input_yiyan_api_api_key.value + config_data["yiyan"]["api"]["secret_key"] = input_yiyan_api_secret_key.value + config_data["yiyan"]["web"]["api_ip_port"] = input_yiyan_web_api_ip_port.value + config_data["yiyan"]["web"]["cookie"] = input_yiyan_web_cookie.value config_data["tongyi"]["type"] = select_tongyi_type.value config_data["tongyi"]["cookie_path"] = input_tongyi_cookie_path.value @@ -1449,19 +1453,25 @@ def common_textarea_handle(content): with ui.card().style(card_css): ui.label("文心一言") with ui.row(): - input_yiyan_api_ip_port = ui.input(label='API地址', placeholder='yiyan-api启动后监听的ip端口地址', value=config.get("yiyan", "api_ip_port")) - input_yiyan_api_ip_port.style("width:400px") - lines = ['web'] + lines = ['api', 'web'] data_json = {} for line in lines: data_json[line] = line select_yiyan_type = ui.select( - label='模型', + label='类型', options=data_json, value=config.get("yiyan", "type") - ) - input_yiyan_cookie = ui.input(label='cookie', placeholder='文心一言登录后,跳过debug后,抓取请求包中的cookie', value=config.get("yiyan", "cookie")) - input_yiyan_cookie.style("width:400px") + ).style("width:100px") + switch_yiyan_history_enable = ui.switch('上下文记忆', value=config.get("yiyan", "history_enable")) + input_yiyan_history_max_len = ui.input(label='最大记忆长度', value=config.get("yiyan", "history_max_len"), placeholder='最长能记忆的问答字符串长度,超长会丢弃最早记忆的内容,请慎用!配置过大可能会有丢大米') + with ui.row(): + input_yiyan_api_api_key = ui.input(label='API Key', placeholder='千帆大模型 应用接入的API Key', value=config.get("yiyan", "api", "api_key")) + input_yiyan_api_secret_key = ui.input(label='Secret Key', placeholder='千帆大模型 应用接入的Secret Key', value=config.get("yiyan", "api", "secret_key")) + with ui.row(): + input_yiyan_web_api_ip_port = ui.input(label='API地址', placeholder='yiyan-api启动后监听的ip端口地址', value=config.get("yiyan", "web", "api_ip_port")) + input_yiyan_web_api_ip_port.style("width:300px") + input_yiyan_web_cookie = ui.input(label='cookie', placeholder='文心一言登录后,跳过debug后,抓取请求包中的cookie', value=config.get("yiyan", "web", "cookie")) + input_yiyan_web_cookie.style("width:300px") with ui.card().style(card_css): ui.label("通义千问") with ui.row():