Skip to content

Commit b619f64

Browse files
committed
fix: azure open ai delta check
1 parent 8331af7 commit b619f64

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
## 3.19.1 – 2025-03-11
3+
4+
1. Fix bug where None is sent as delta in azure
5+
16
## 3.19.0 – 2025-03-04
27

38
1. Add support for tool calls in OpenAI and Anthropic.

posthog/ai/openai/openai.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ def generator():
122122
usage_stats["cache_read_input_tokens"] = chunk.usage.prompt_tokens_details.cached_tokens
123123

124124
if hasattr(chunk, "choices") and chunk.choices and len(chunk.choices) > 0:
125-
content = chunk.choices[0].delta.content
126-
if content:
127-
accumulated_content.append(content)
125+
if chunk.choices[0].delta and chunk.choices[0].delta.content:
126+
content = chunk.choices[0].delta.content
127+
if content:
128+
accumulated_content.append(content)
128129

129130
# Process tool calls
130131
tool_calls = getattr(chunk.choices[0].delta, "tool_calls", None)

posthog/ai/openai/openai_async.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ async def async_generator():
120120
usage_stats["cache_read_input_tokens"] = chunk.usage.prompt_tokens_details.cached_tokens
121121

122122
if hasattr(chunk, "choices") and chunk.choices and len(chunk.choices) > 0:
123-
content = chunk.choices[0].delta.content
124-
if content:
125-
accumulated_content.append(content)
123+
if chunk.choices[0].delta and chunk.choices[0].delta.content:
124+
content = chunk.choices[0].delta.content
125+
if content:
126+
accumulated_content.append(content)
126127

127128
# Process tool calls
128129
tool_calls = getattr(chunk.choices[0].delta, "tool_calls", None)

posthog/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = "3.19.0"
1+
VERSION = "3.19.1"
22

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

0 commit comments

Comments
 (0)