mirror of
https://github.com/TeamWiseFlow/wiseflow.git
synced 2025-01-23 02:20:20 +08:00
repair openai wrapper
This commit is contained in:
parent
60df751129
commit
61e3c042b4
@ -29,8 +29,10 @@ def openai_llm(messages: list, model: str, logger=None, **kwargs) -> str:
|
||||
logger.warning(f'{e}\nRetrying in 60 second...')
|
||||
time.sleep(60)
|
||||
response = client.chat.completions.create(messages=messages, model=model, **kwargs)
|
||||
if 'choices' not in response:
|
||||
logger.warning(f'openai_llm warning: {response}')
|
||||
if response and response.choices:
|
||||
return response.choices[0].message.content
|
||||
else:
|
||||
logger.error(f'after many try, llm error: {response}')
|
||||
return ""
|
||||
except Exception as e:
|
||||
if logger:
|
||||
|
Loading…
Reference in New Issue
Block a user