Skip to content

Conversation

@k11kirky
Copy link
Contributor

Add a check for delta before getting contents otherwise azure will not work with streaming

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added a critical fix for Azure OpenAI streaming responses by implementing proper null checks for delta properties.

  • Added null checks for delta and delta.content in both sync and async OpenAI clients at posthog/ai/openai/openai.py and posthog/ai/openai/openai_async.py
  • Version bumped to 3.19.1 in posthog/version.py to reflect the bug fix
  • Updated CHANGELOG.md with Azure OpenAI streaming fix entry

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

accumulated_content.append(content)

# Process tool calls
tool_calls = getattr(chunk.choices[0].delta, "tool_calls", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding the same null check for delta before accessing tool_calls to maintain consistency with the content check above

@k11kirky k11kirky merged commit 28a7d35 into master Mar 10, 2025
6 checks passed
@k11kirky k11kirky deleted the fiz/azure-openai branch March 10, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants