Skip to content

Commit

Permalink
proxy后向兼容,修复部分报错
Browse files Browse the repository at this point in the history
  • Loading branch information
LINSTCL committed Mar 3, 2023
1 parent c57642b commit c23d114
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/openai/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/openai/modelmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c23d114

Please sign in to comment.