diff --git a/pkg/openai/manager.py b/pkg/openai/manager.py index cfafbd84..e5cef33d 100644 --- a/pkg/openai/manager.py +++ b/pkg/openai/manager.py @@ -39,7 +39,7 @@ def request_completion(self, prompts): ai: ModelRequest = create_openai_model_request( config.completion_api_params['model'], 'user', - config.openai_config["http_proxy"] + config.openai_config["http_proxy"] if "http_proxy" in config.openai_config else None ) ai.request( prompts, diff --git a/pkg/openai/modelmgr.py b/pkg/openai/modelmgr.py index 4bffc7b4..64d427a1 100644 --- a/pkg/openai/modelmgr.py +++ b/pkg/openai/modelmgr.py @@ -45,8 +45,9 @@ async def __a_request__(self, **kwargs): def request(self, **kwargs): if self.proxy != None: #异步请求 + loop = asyncio.new_event_loop() self.runtime = threading.Thread( - target=asyncio.run, + target=loop.run_until_complete, args=(self.__a_request__(**kwargs),) ) self.runtime.start()