diff --git a/CHANGELOG.md b/CHANGELOG.md index a839993c..2449c40d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/posthog/ai/openai/openai.py b/posthog/ai/openai/openai.py index ad425382..3d88b169 100644 --- a/posthog/ai/openai/openai.py +++ b/posthog/ai/openai/openai.py @@ -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) diff --git a/posthog/ai/openai/openai_async.py b/posthog/ai/openai/openai_async.py index b7f9ce11..9c2ed984 100644 --- a/posthog/ai/openai/openai_async.py +++ b/posthog/ai/openai/openai_async.py @@ -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) diff --git a/posthog/version.py b/posthog/version.py index 7610a2fe..7b5d56f5 100644 --- a/posthog/version.py +++ b/posthog/version.py @@ -1,4 +1,4 @@ -VERSION = "3.19.0" +VERSION = "3.19.1" if __name__ == "__main__": print(VERSION, end="") # noqa: T201