(request: gradio.Request, cookies:dict, max_length:int, llm_model:str,
txt:str, txt2:str, top_p:float, temperature:float, chatbot:list,
json_history:str, system_prompt:str, plugin_advanced_arg:dict, *args)
| 92 | 函数示意图:https://mermaid.live/edit#pako:eNqNVFtPGkEY_StkntoEDQtLoTw0sWqapjQxVWPabmOm7AiEZZcsQ9QiiW012qixqdeqqIn10geBh6ZR8PJnmAWe-hc6l3VhrWnLEzNzzvnO953ZyYOYoSIQAWOaMR5LQBN7hvoU3UN_g5iu7imAXEyT4wUF3Pd0dT3y9KGYYUJsmK8V0GPGs0-QjkyojZgwk0Fm82C2dVghX08U8EaoOHjOfoEMU0XmADRhOksVWnNLjdpM82qFzB6S5Q_WWsUhuqCc3JtAsVR_OoMnhyZwXgHWwbS1d4gnsLVZJp-P6mfVxveqAgqC70Jz_pQCOGDKM5xFdNNPDdilF6uSU_hOYqu4a3MHYDZLDzq5fodrC3PWcEaFGPUaRiqJWK_W9g9rvRITa4dhy_0nw67SiePMp3oSR6PPn41DGgllkvkizYwsrmtaejTFd8V4yekGmT1zqrt4XGlAy8WTuiPULF01LksZvukSajfQQRAxmYi5S0D81sDcyzapVdn6sYFHkjhhGyel3frVQnvsnbR23lEjlhIlaOJiFPWzU5G4tfNJo8ejwp47-TbvJkKKZvmxA6SKo16oaazJysfG6klr9T0pbTW2ZqzlL_XaT8fYbQLXe4mSmvoCZXMaa7FePW6s7jVqK9bujvse3WFjY5_Z4KfsA4oiPY4T7Drvn1tLJTbG1to1qR79ulgk89-oJbvZzbIwJty6u20LOReWa9BvwserUd9s9MIKc3x5TUWEoAhUyJK5y85w_yG-dFu_R9waoU7K581y8W_qLle35-rG9Nxcrz8QHRsc0K-r9NViYRT36KsFvCCNzDRMqvSVyzOKAnACpZECIvSvCs2UAhS9QHEwh43BST0GItjMIS_I8e-sLwnj9A262cxA_ZVh0OUY1LJiDSJ5MAEiUijYLUtBORR6KElyQPaCSRDpksNSd8AfluSgHPaFC17wjrOlbgbzyyFf4IFPDvoD_sJvnkdK-g |
| 93 | """ |
| 94 | def decorated(request: gradio.Request, cookies:dict, max_length:int, llm_model:str, |
| 95 | txt:str, txt2:str, top_p:float, temperature:float, chatbot:list, |
| 96 | json_history:str, system_prompt:str, plugin_advanced_arg:dict, *args): |
| 97 | txt_passon = txt |
| 98 | history = json.loads(json_history) if json_history else [] |
| 99 | if txt == "" and txt2 != "": txt_passon = txt2 |
| 100 | # 引入一个有cookie的chatbot |
| 101 | if request.username is not None: |
| 102 | user_name = request.username |
| 103 | else: |
| 104 | user_name = default_user_name |
| 105 | embed_model = get_conf("EMBEDDING_MODEL") |
| 106 | cookies.update({ |
| 107 | 'top_p': top_p, |
| 108 | 'api_key': cookies['api_key'], |
| 109 | 'llm_model': llm_model, |
| 110 | 'embed_model': embed_model, |
| 111 | 'temperature': temperature, |
| 112 | 'user_name': user_name, |
| 113 | }) |
| 114 | llm_kwargs = { |
| 115 | 'api_key': cookies['api_key'], |
| 116 | 'llm_model': llm_model, |
| 117 | 'embed_model': embed_model, |
| 118 | 'top_p': top_p, |
| 119 | 'max_length': max_length, |
| 120 | 'temperature': temperature, |
| 121 | 'client_ip': request.client.host, |
| 122 | 'most_recent_uploaded': cookies.get('most_recent_uploaded') |
| 123 | } |
| 124 | if isinstance(plugin_advanced_arg, str): |
| 125 | plugin_kwargs = {"advanced_arg": plugin_advanced_arg} |
| 126 | else: |
| 127 | plugin_kwargs = plugin_advanced_arg |
| 128 | chatbot_with_cookie = ChatBotWithCookies(cookies) |
| 129 | chatbot_with_cookie.write_list(chatbot) |
| 130 | |
| 131 | if cookies.get('lock_plugin', None) is None: |
| 132 | # 正常状态 |
| 133 | if len(args) == 0: # 插件通道 |
| 134 | yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, request) |
| 135 | else: # 对话通道,或者基础功能通道 |
| 136 | yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, *args) |
| 137 | else: |
| 138 | # 处理少数情况下的特殊插件的锁定状态 |
| 139 | module, fn_name = cookies['lock_plugin'].split('->') |
| 140 | f_hot_reload = getattr(importlib.import_module(module, fn_name), fn_name) |
| 141 | yield from f_hot_reload(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, request) |
| 142 | # 判断一下用户是否错误地通过对话通道进入,如果是,则进行提醒 |
| 143 | final_cookies = chatbot_with_cookie.get_cookies() |
| 144 | # len(args) != 0 代表“提交”键对话通道,或者基础功能通道 |
| 145 | if len(args) != 0 and 'files_to_promote' in final_cookies and len(final_cookies['files_to_promote']) > 0: |
| 146 | chatbot_with_cookie.append( |
| 147 | ["检测到**滞留的缓存文档**,请及时处理。", "请及时点击“**保存当前对话**”获取所有滞留文档。"]) |
| 148 | yield from update_ui(chatbot_with_cookie, final_cookies['history'], msg="检测到被滞留的缓存文档") |
| 149 | |
| 150 | return decorated |
| 151 |
nothing calls this directly
no test coverage detected