mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-26 03:44:58 +08:00
proxy后向兼容,修复部分报错
This commit is contained in:
@@ -39,7 +39,7 @@ class OpenAIInteract:
|
|||||||
ai: ModelRequest = create_openai_model_request(
|
ai: ModelRequest = create_openai_model_request(
|
||||||
config.completion_api_params['model'],
|
config.completion_api_params['model'],
|
||||||
'user',
|
'user',
|
||||||
config.openai_config["http_proxy"]
|
config.openai_config["http_proxy"] if "http_proxy" in config.openai_config else None
|
||||||
)
|
)
|
||||||
ai.request(
|
ai.request(
|
||||||
prompts,
|
prompts,
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ class ModelRequest():
|
|||||||
|
|
||||||
def request(self, **kwargs):
|
def request(self, **kwargs):
|
||||||
if self.proxy != None: #异步请求
|
if self.proxy != None: #异步请求
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
self.runtime = threading.Thread(
|
self.runtime = threading.Thread(
|
||||||
target=asyncio.run,
|
target=loop.run_until_complete,
|
||||||
args=(self.__a_request__(**kwargs),)
|
args=(self.__a_request__(**kwargs),)
|
||||||
)
|
)
|
||||||
self.runtime.start()
|
self.runtime.start()
|
||||||
|
|||||||
Reference in New Issue
Block a user