Skip to content

Conversation

@BryceAmackerLE
Copy link
Contributor

@BryceAmackerLE BryceAmackerLE commented Jan 7, 2024

Description

When using AzureOpenAI() with stream_chat or astream_chat, occasionally the Azure API will return empty responses initially. Adding a check and simply continuing until the next response seems to fix this issue. This issue is described in the following posts:
#9219
run-llama/sec-insights#64
run-llama/sec-insights#78

Fixes #9219

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Used the test code provided by @fchenGT in #9219, and implemented fix in Azure version of https://github.com/run-llama/sec-insights

Suggested Checklist:

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jan 7, 2024
else:
delta = ChoiceDelta()
if self._is_azure_client():
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it cause some missing data if delta is not returning properly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't -- azure is kind of mis-using the API by returning chunks with no content at the start (instead, it has some safety info or something silly)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 8, 2024
@logan-markewich logan-markewich merged commit d9954d8 into run-llama:main Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAIAgent using AzureOpenAI not working with stream_chat and astream_chat

3 participants