Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

## 3.19.1 – 2025-03-11

1. Fix bug where None is sent as delta in azure

## 3.19.0 – 2025-03-04

1. Add support for tool calls in OpenAI and Anthropic.
Expand Down
7 changes: 4 additions & 3 deletions posthog/ai/openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ def generator():
usage_stats["cache_read_input_tokens"] = chunk.usage.prompt_tokens_details.cached_tokens

if hasattr(chunk, "choices") and chunk.choices and len(chunk.choices) > 0:
content = chunk.choices[0].delta.content
if content:
accumulated_content.append(content)
if chunk.choices[0].delta and chunk.choices[0].delta.content:
content = chunk.choices[0].delta.content
if content:
accumulated_content.append(content)

# Process tool calls
tool_calls = getattr(chunk.choices[0].delta, "tool_calls", None)
Expand Down
7 changes: 4 additions & 3 deletions posthog/ai/openai/openai_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ async def async_generator():
usage_stats["cache_read_input_tokens"] = chunk.usage.prompt_tokens_details.cached_tokens

if hasattr(chunk, "choices") and chunk.choices and len(chunk.choices) > 0:
content = chunk.choices[0].delta.content
if content:
accumulated_content.append(content)
if chunk.choices[0].delta and chunk.choices[0].delta.content:
content = chunk.choices[0].delta.content
if content:
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

Expand Down
2 changes: 1 addition & 1 deletion posthog/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "3.19.0"
VERSION = "3.19.1"

if __name__ == "__main__":
print(VERSION, end="") # noqa: T201