优化autogen的使用
This commit is contained in:
		
							parent
							
								
									e2b3c47186
								
							
						
					
					
						commit
						27c4e3ef4f
					
				@ -83,8 +83,9 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
 | 
					# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
 | 
				
			||||||
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
 | 
					LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
 | 
				
			||||||
AVAIL_LLM_MODELS = ["gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5", "api2d-gpt-3.5-turbo",
 | 
					AVAIL_LLM_MODELS = ["gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
 | 
				
			||||||
                    "gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "stack-claude"]
 | 
					                    "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "api2d-gpt-4",
 | 
				
			||||||
 | 
					                    "gpt-4", "gpt-4-32k", "azure-gpt-4", "chatglm", "moss", "newbing", "stack-claude"]
 | 
				
			||||||
# P.S. 其他可用的模型还包括 ["qianfan", "llama2", "qwen", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613",  "gpt-3.5-random"
 | 
					# P.S. 其他可用的模型还包括 ["qianfan", "llama2", "qwen", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613",  "gpt-3.5-random"
 | 
				
			||||||
# "spark", "sparkv2", "chatglm_onnx", "claude-1-100k", "claude-2", "internlm", "jittorllms_pangualpha", "jittorllms_llama"]
 | 
					# "spark", "sparkv2", "chatglm_onnx", "claude-1-100k", "claude-2", "internlm", "jittorllms_pangualpha", "jittorllms_llama"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -191,6 +192,10 @@ GROBID_URLS = [
 | 
				
			|||||||
ALLOW_RESET_CONFIG = False
 | 
					ALLOW_RESET_CONFIG = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 在使用AutoGen插件时,是否使用Docker容器运行代码
 | 
				
			||||||
 | 
					AUTOGEN_USE_DOCKER = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 临时的上传文件夹位置,请勿修改
 | 
					# 临时的上传文件夹位置,请勿修改
 | 
				
			||||||
PATH_PRIVATE_UPLOAD = "private_upload"
 | 
					PATH_PRIVATE_UPLOAD = "private_upload"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -539,18 +539,18 @@ def get_crazy_functions():
 | 
				
			|||||||
    except:
 | 
					    except:
 | 
				
			||||||
        print('Load function plugin failed')
 | 
					        print('Load function plugin failed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # try:
 | 
					    try:
 | 
				
			||||||
    #     from crazy_functions.多智能体 import 多智能体终端
 | 
					        from crazy_functions.多智能体 import 多智能体终端
 | 
				
			||||||
    #     function_plugins.update({
 | 
					        function_plugins.update({
 | 
				
			||||||
    #         "多智能体终端(微软AutoGen)": {
 | 
					            "多智能体终端(微软AutoGen)": {
 | 
				
			||||||
    #             "Group": "智能体",
 | 
					                "Group": "智能体",
 | 
				
			||||||
    #             "Color": "stop",
 | 
					                "Color": "stop",
 | 
				
			||||||
    #             "AsButton": True,
 | 
					                "AsButton": True,
 | 
				
			||||||
    #             "Function": HotReload(多智能体终端)
 | 
					                "Function": HotReload(多智能体终端)
 | 
				
			||||||
    #         }
 | 
					            }
 | 
				
			||||||
    #     })
 | 
					        })
 | 
				
			||||||
    # except:
 | 
					    except:
 | 
				
			||||||
    #     print('Load function plugin failed')
 | 
					        print('Load function plugin failed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # try:
 | 
					    # try:
 | 
				
			||||||
    #     from crazy_functions.chatglm微调工具 import 微调数据集生成
 | 
					    #     from crazy_functions.chatglm微调工具 import 微调数据集生成
 | 
				
			||||||
 | 
				
			|||||||
@ -36,12 +36,8 @@ class AutoGenGeneral(PluginMultiprocessManager):
 | 
				
			|||||||
        # ⭐⭐ 子进程执行
 | 
					        # ⭐⭐ 子进程执行
 | 
				
			||||||
        input = input.content
 | 
					        input = input.content
 | 
				
			||||||
        with ProxyNetworkActivate("AutoGen"):
 | 
					        with ProxyNetworkActivate("AutoGen"):
 | 
				
			||||||
            from autogen import AssistantAgent, UserProxyAgent
 | 
					            config_list = self.get_config_list()
 | 
				
			||||||
            config_list = [{
 | 
					            code_execution_config={"work_dir": self.autogen_work_dir, "use_docker":self.use_docker}
 | 
				
			||||||
                'model': self.llm_kwargs['llm_model'], 
 | 
					 | 
				
			||||||
                'api_key': self.llm_kwargs['api_key'],
 | 
					 | 
				
			||||||
            },]
 | 
					 | 
				
			||||||
            code_execution_config={"work_dir": self.autogen_work_dir, "use_docker":True}
 | 
					 | 
				
			||||||
            agents = self.define_agents()
 | 
					            agents = self.define_agents()
 | 
				
			||||||
            user_proxy = None
 | 
					            user_proxy = None
 | 
				
			||||||
            assistant = None
 | 
					            assistant = None
 | 
				
			||||||
@ -67,6 +63,20 @@ class AutoGenGeneral(PluginMultiprocessManager):
 | 
				
			|||||||
                tb_str = '```\n' + trimmed_format_exc() + '```'
 | 
					                tb_str = '```\n' + trimmed_format_exc() + '```'
 | 
				
			||||||
                self.child_conn.send(PipeCom("done", "AutoGen 执行失败: \n\n" + tb_str))
 | 
					                self.child_conn.send(PipeCom("done", "AutoGen 执行失败: \n\n" + tb_str))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_config_list(self):
 | 
				
			||||||
 | 
					        model = self.llm_kwargs['llm_model']
 | 
				
			||||||
 | 
					        api_base = None
 | 
				
			||||||
 | 
					        if self.llm_kwargs['llm_model'].startswith('api2d-'):
 | 
				
			||||||
 | 
					            model = self.llm_kwargs['llm_model'][len('api2d-'):]
 | 
				
			||||||
 | 
					            api_base = "https://openai.api2d.net/v1"
 | 
				
			||||||
 | 
					        config_list = [{
 | 
				
			||||||
 | 
					                'model': model, 
 | 
				
			||||||
 | 
					                'api_key': self.llm_kwargs['api_key'],
 | 
				
			||||||
 | 
					            },]
 | 
				
			||||||
 | 
					        if api_base is not None:
 | 
				
			||||||
 | 
					            config_list[0]['api_base'] = api_base
 | 
				
			||||||
 | 
					        return config_list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def subprocess_worker(self, child_conn):
 | 
					    def subprocess_worker(self, child_conn):
 | 
				
			||||||
        # ⭐⭐ 子进程执行
 | 
					        # ⭐⭐ 子进程执行
 | 
				
			||||||
        self.child_conn = child_conn
 | 
					        self.child_conn = child_conn
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
from toolbox import get_log_folder, update_ui, gen_time_str, trimmed_format_exc, promote_file_to_downloadzone
 | 
					from toolbox import get_log_folder, update_ui, gen_time_str, get_conf, promote_file_to_downloadzone
 | 
				
			||||||
 | 
					from crazy_functions.agent_fns.watchdog import WatchDog
 | 
				
			||||||
import time, os
 | 
					import time, os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PipeCom():
 | 
					class PipeCom():
 | 
				
			||||||
@ -19,6 +20,16 @@ class PluginMultiprocessManager():
 | 
				
			|||||||
        self.system_prompt = system_prompt
 | 
					        self.system_prompt = system_prompt
 | 
				
			||||||
        self.web_port = web_port
 | 
					        self.web_port = web_port
 | 
				
			||||||
        self.alive = True
 | 
					        self.alive = True
 | 
				
			||||||
 | 
					        self.use_docker, = get_conf('AUTOGEN_USE_DOCKER')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # create a thread to monitor self.heartbeat, terminate the instance if no heartbeat for a long time
 | 
				
			||||||
 | 
					        timeout_seconds = 5*60
 | 
				
			||||||
 | 
					        self.heartbeat_watchdog = WatchDog(timeout=timeout_seconds, bark_fn=self.terminate, interval=5)
 | 
				
			||||||
 | 
					        self.heartbeat_watchdog.begin_watch()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def feed_heartbeat_watchdog(self):
 | 
				
			||||||
 | 
					        # feed this `dog`, so the dog will not `bark` (bark_fn will terminate the instance)
 | 
				
			||||||
 | 
					        self.heartbeat_watchdog.feed()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def is_alive(self):
 | 
					    def is_alive(self):
 | 
				
			||||||
        return self.alive
 | 
					        return self.alive
 | 
				
			||||||
@ -50,7 +61,7 @@ class PluginMultiprocessManager():
 | 
				
			|||||||
        # 获取fp的拓展名
 | 
					        # 获取fp的拓展名
 | 
				
			||||||
        file_type = fp.split('.')[-1]
 | 
					        file_type = fp.split('.')[-1]
 | 
				
			||||||
        # 如果是文本文件, 则直接显示文本内容
 | 
					        # 如果是文本文件, 则直接显示文本内容
 | 
				
			||||||
        if file_type in ['png', 'jpg']:
 | 
					        if file_type.lower() in ['png', 'jpg']:
 | 
				
			||||||
            image_path = os.path.abspath(fp)
 | 
					            image_path = os.path.abspath(fp)
 | 
				
			||||||
            self.chatbot.append(['检测到新生图像:', f'本地文件预览: <br/><div align="center"><img src="file={image_path}"></div>'])
 | 
					            self.chatbot.append(['检测到新生图像:', f'本地文件预览: <br/><div align="center"><img src="file={image_path}"></div>'])
 | 
				
			||||||
            yield from update_ui(chatbot=self.chatbot, history=self.history)
 | 
					            yield from update_ui(chatbot=self.chatbot, history=self.history)
 | 
				
			||||||
@ -98,9 +109,17 @@ class PluginMultiprocessManager():
 | 
				
			|||||||
            self.terminate()
 | 
					            self.terminate()
 | 
				
			||||||
            return "terminate"
 | 
					            return "terminate"
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        # patience = 10
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        while True:
 | 
					        while True:
 | 
				
			||||||
            time.sleep(0.5)
 | 
					            time.sleep(0.5)
 | 
				
			||||||
 | 
					            if not self.alive:
 | 
				
			||||||
 | 
					                # the heartbeat watchdog might have it killed
 | 
				
			||||||
 | 
					                self.terminate()
 | 
				
			||||||
 | 
					                return "terminate"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if self.parent_conn.poll(): 
 | 
					            if self.parent_conn.poll(): 
 | 
				
			||||||
 | 
					                self.feed_heartbeat_watchdog()
 | 
				
			||||||
                if '[GPT-Academic] 等待中' in self.chatbot[-1][-1]:
 | 
					                if '[GPT-Academic] 等待中' in self.chatbot[-1][-1]:
 | 
				
			||||||
                    self.chatbot.pop(-1)    # remove the last line
 | 
					                    self.chatbot.pop(-1)    # remove the last line
 | 
				
			||||||
                msg = self.parent_conn.recv() # PipeCom
 | 
					                msg = self.parent_conn.recv() # PipeCom
 | 
				
			||||||
@ -124,10 +143,17 @@ class PluginMultiprocessManager():
 | 
				
			|||||||
                    # do not terminate here, leave the subprocess_worker instance alive
 | 
					                    # do not terminate here, leave the subprocess_worker instance alive
 | 
				
			||||||
                    return "wait_feedback"
 | 
					                    return "wait_feedback"
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
 | 
					                self.feed_heartbeat_watchdog()
 | 
				
			||||||
                if '[GPT-Academic] 等待中' not in self.chatbot[-1][-1]:
 | 
					                if '[GPT-Academic] 等待中' not in self.chatbot[-1][-1]:
 | 
				
			||||||
 | 
					                    # begin_waiting_time = time.time()
 | 
				
			||||||
                    self.chatbot.append(["[GPT-Academic] 等待AutoGen执行结果 ...", "[GPT-Academic] 等待中"])
 | 
					                    self.chatbot.append(["[GPT-Academic] 等待AutoGen执行结果 ...", "[GPT-Academic] 等待中"])
 | 
				
			||||||
                self.chatbot[-1] = [self.chatbot[-1][0], self.chatbot[-1][1].replace("[GPT-Academic] 等待中", "[GPT-Academic] 等待中.")]
 | 
					                self.chatbot[-1] = [self.chatbot[-1][0], self.chatbot[-1][1].replace("[GPT-Academic] 等待中", "[GPT-Academic] 等待中.")]
 | 
				
			||||||
                yield from update_ui(chatbot=self.chatbot, history=self.history)
 | 
					                yield from update_ui(chatbot=self.chatbot, history=self.history)
 | 
				
			||||||
 | 
					                # if time.time() - begin_waiting_time > patience:
 | 
				
			||||||
 | 
					                #     self.chatbot.append([f"结束", "等待超时, 终止AutoGen程序。"])
 | 
				
			||||||
 | 
					                #     yield from update_ui(chatbot=self.chatbot, history=self.history)
 | 
				
			||||||
 | 
					                #     self.terminate()
 | 
				
			||||||
 | 
					                #     return "terminate"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.terminate()
 | 
					        self.terminate()
 | 
				
			||||||
        return "terminate"
 | 
					        return "terminate"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										28
									
								
								crazy_functions/agent_fns/watchdog.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								crazy_functions/agent_fns/watchdog.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					import threading, time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class WatchDog():
 | 
				
			||||||
 | 
					    def __init__(self, timeout, bark_fn, interval=3, msg="") -> None:
 | 
				
			||||||
 | 
					        self.last_feed = None
 | 
				
			||||||
 | 
					        self.timeout = timeout
 | 
				
			||||||
 | 
					        self.bark_fn = bark_fn
 | 
				
			||||||
 | 
					        self.interval = interval
 | 
				
			||||||
 | 
					        self.msg = msg
 | 
				
			||||||
 | 
					        self.kill_dog = False
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    def watch(self):
 | 
				
			||||||
 | 
					        while True:
 | 
				
			||||||
 | 
					            if self.kill_dog: break
 | 
				
			||||||
 | 
					            if time.time() - self.last_feed > self.timeout:
 | 
				
			||||||
 | 
					                if len(self.msg) > 0: print(self.msg)
 | 
				
			||||||
 | 
					                self.bark_fn()
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					            time.sleep(self.interval)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def begin_watch(self):
 | 
				
			||||||
 | 
					        self.last_feed = time.time()
 | 
				
			||||||
 | 
					        th = threading.Thread(target=self.watch)
 | 
				
			||||||
 | 
					        th.daemon = True
 | 
				
			||||||
 | 
					        th.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def feed(self):
 | 
				
			||||||
 | 
					        self.last_feed = time.time()
 | 
				
			||||||
@ -1,10 +1,7 @@
 | 
				
			|||||||
# 本源代码中, ⭐ = 关键步骤
 | 
					# 本源代码中, ⭐ = 关键步骤
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
测试:
 | 
					测试:
 | 
				
			||||||
    - 裁剪图像,保留下半部分
 | 
					    - show me the solution of $x^2=cos(x)$, solve this problem with figure, and plot and save image to t.jpg
 | 
				
			||||||
    - 交换图像的蓝色通道和红色通道
 | 
					 | 
				
			||||||
    - 将图像转为灰度图像
 | 
					 | 
				
			||||||
    - 将csv文件转excel表格
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Testing: 
 | 
					Testing: 
 | 
				
			||||||
    - Crop the image, keeping the bottom half. 
 | 
					    - Crop the image, keeping the bottom half. 
 | 
				
			||||||
@ -35,7 +32,8 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
 | 
				
			|||||||
    web_port        当前软件运行的端口号
 | 
					    web_port        当前软件运行的端口号
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    # 检查当前的模型是否符合要求
 | 
					    # 检查当前的模型是否符合要求
 | 
				
			||||||
    supported_llms = ['gpt-3.5-turbo-16k', 'gpt-4', 'gpt-4-32k']
 | 
					    supported_llms = ['gpt-3.5-turbo-16k', 'gpt-4', 'gpt-4-32k', 
 | 
				
			||||||
 | 
					                      'api2d-gpt-3.5-turbo-16k', 'api2d-gpt-4']
 | 
				
			||||||
    llm_kwargs['api_key'] = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
 | 
					    llm_kwargs['api_key'] = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
 | 
				
			||||||
    if llm_kwargs['llm_model'] not in supported_llms:
 | 
					    if llm_kwargs['llm_model'] not in supported_llms:
 | 
				
			||||||
        chatbot.append([f"处理任务: {txt}", f"当前插件只支持{str(supported_llms)}, 当前模型{llm_kwargs['llm_model']}."])
 | 
					        chatbot.append([f"处理任务: {txt}", f"当前插件只支持{str(supported_llms)}, 当前模型{llm_kwargs['llm_model']}."])
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
from toolbox import update_ui
 | 
					from toolbox import update_ui
 | 
				
			||||||
from toolbox import CatchException, get_conf, markdown_convertion
 | 
					from toolbox import CatchException, get_conf, markdown_convertion
 | 
				
			||||||
from crazy_functions.crazy_utils import input_clipping
 | 
					from crazy_functions.crazy_utils import input_clipping
 | 
				
			||||||
 | 
					from crazy_functions.agent_fns.watchdog import WatchDog
 | 
				
			||||||
from request_llm.bridge_all import predict_no_ui_long_connection
 | 
					from request_llm.bridge_all import predict_no_ui_long_connection
 | 
				
			||||||
import threading, time
 | 
					import threading, time
 | 
				
			||||||
import numpy as np
 | 
					import numpy as np
 | 
				
			||||||
@ -8,32 +9,6 @@ from .live_audio.aliyunASR import AliyunASR
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WatchDog():
 | 
					 | 
				
			||||||
    def __init__(self, timeout, bark_fn, interval=3, msg="") -> None:
 | 
					 | 
				
			||||||
        self.last_feed = None
 | 
					 | 
				
			||||||
        self.timeout = timeout
 | 
					 | 
				
			||||||
        self.bark_fn = bark_fn
 | 
					 | 
				
			||||||
        self.interval = interval
 | 
					 | 
				
			||||||
        self.msg = msg
 | 
					 | 
				
			||||||
        self.kill_dog = False
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    def watch(self):
 | 
					 | 
				
			||||||
        while True:
 | 
					 | 
				
			||||||
            if self.kill_dog: break
 | 
					 | 
				
			||||||
            if time.time() - self.last_feed > self.timeout:
 | 
					 | 
				
			||||||
                if len(self.msg) > 0: print(self.msg)
 | 
					 | 
				
			||||||
                self.bark_fn()
 | 
					 | 
				
			||||||
                break
 | 
					 | 
				
			||||||
            time.sleep(self.interval)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def begin_watch(self):
 | 
					 | 
				
			||||||
        self.last_feed = time.time()
 | 
					 | 
				
			||||||
        th = threading.Thread(target=self.watch)
 | 
					 | 
				
			||||||
        th.daemon = True
 | 
					 | 
				
			||||||
        th.start()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def feed(self):
 | 
					 | 
				
			||||||
        self.last_feed = time.time()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def chatbot2history(chatbot):
 | 
					def chatbot2history(chatbot):
 | 
				
			||||||
    history = []
 | 
					    history = []
 | 
				
			||||||
 | 
				
			|||||||
@ -182,6 +182,15 @@ model_info = {
 | 
				
			|||||||
        "token_cnt": get_token_num_gpt4,
 | 
					        "token_cnt": get_token_num_gpt4,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "api2d-gpt-3.5-turbo-16k": {
 | 
				
			||||||
 | 
					        "fn_with_ui": chatgpt_ui,
 | 
				
			||||||
 | 
					        "fn_without_ui": chatgpt_noui,
 | 
				
			||||||
 | 
					        "endpoint": api2d_endpoint,
 | 
				
			||||||
 | 
					        "max_token": 1024*16,
 | 
				
			||||||
 | 
					        "tokenizer": tokenizer_gpt35,
 | 
				
			||||||
 | 
					        "token_cnt": get_token_num_gpt35,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 将 chatglm 直接对齐到 chatglm2
 | 
					    # 将 chatglm 直接对齐到 chatglm2
 | 
				
			||||||
    "chatglm": {
 | 
					    "chatglm": {
 | 
				
			||||||
        "fn_with_ui": chatglm_ui,
 | 
					        "fn_with_ui": chatglm_ui,
 | 
				
			||||||
 | 
				
			|||||||
@ -314,7 +314,10 @@ def generate_payload(inputs, llm_kwargs, history, system_prompt, stream):
 | 
				
			|||||||
    what_i_ask_now["role"] = "user"
 | 
					    what_i_ask_now["role"] = "user"
 | 
				
			||||||
    what_i_ask_now["content"] = inputs
 | 
					    what_i_ask_now["content"] = inputs
 | 
				
			||||||
    messages.append(what_i_ask_now)
 | 
					    messages.append(what_i_ask_now)
 | 
				
			||||||
    model = llm_kwargs['llm_model'].strip('api2d-')
 | 
					    model = llm_kwargs['llm_model']
 | 
				
			||||||
 | 
					    if llm_kwargs['llm_model'].startswith('api2d-'):
 | 
				
			||||||
 | 
					        model = llm_kwargs['llm_model'][len('api2d-'):]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if model == "gpt-3.5-random": # 随机选择, 绕过openai访问频率限制
 | 
					    if model == "gpt-3.5-random": # 随机选择, 绕过openai访问频率限制
 | 
				
			||||||
        model = random.choice([
 | 
					        model = random.choice([
 | 
				
			||||||
            "gpt-3.5-turbo", 
 | 
					            "gpt-3.5-turbo", 
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user