Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
braisedpork1964 committed Oct 24, 2024
1 parent 5e6055c commit 573c7b5
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lagent/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _chat(self, messages: List[dict], **gen_params) -> str:
response['error'])
self.logger.error(errmsg)
except Exception as error:
errmsg = str(error) + ' ' + str(traceback.format_exc())
errmsg = str(error) + '\n' + str(traceback.format_exc())
self.logger.error(errmsg)
max_num_retries += 1

Expand Down Expand Up @@ -293,10 +293,9 @@ def streaming(raw_response):
return
yield choice['delta'].get('content', '')
except Exception as exc:
print(
f'response {decoded} lead to exception of {str(exc)}'
)
raise
msg = f'response {decoded} lead to exception of {str(exc)}'
self.logger.error(msg)
raise Exception(msg) from exc

assert isinstance(messages, list)

Expand Down Expand Up @@ -359,7 +358,7 @@ def streaming(raw_response):
response['error'])
self.logger.error(errmsg)
except Exception as error:
errmsg = str(error) + ' ' + str(traceback.format_exc())
errmsg = str(error) + '\n' + str(traceback.format_exc())
self.logger.error(errmsg)
max_num_retries += 1

Expand Down Expand Up @@ -694,7 +693,7 @@ async def _chat(self, messages: List[dict], **gen_params) -> str:
response['error'])
self.logger.error(errmsg)
except Exception as error:
errmsg = str(error) + ' ' + str(traceback.format_exc())
errmsg = str(error) + '\n' + str(traceback.format_exc())
self.logger.error(errmsg)
max_num_retries += 1

Expand Down Expand Up @@ -743,10 +742,9 @@ async def streaming(raw_response):
return
yield choice['delta'].get('content', '')
except Exception as exc:
self.logger.error(
f'response {decoded} lead to exception of {str(exc)}'
)
raise
msg = f'response {decoded} lead to exception of {str(exc)}'
self.logger.error(msg)
raise Exception(msg) from exc

assert isinstance(messages, list)

Expand Down Expand Up @@ -814,7 +812,7 @@ async def streaming(raw_response):
response['error'])
self.logger.error(errmsg)
except Exception as error:
errmsg = str(error) + ' ' + str(traceback.format_exc())
errmsg = str(error) + '\n' + str(traceback.format_exc())
self.logger.error(errmsg)
max_num_retries += 1

Expand Down

0 comments on commit 573c7b5

Please sign in to comment.