Skip to content

Commit af85f25

Browse files
committed
fix: types
1 parent 784bc2d commit af85f25

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

posthog/test/ai/openai/test_openai.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
from unittest.mock import patch
44

55
import pytest
6-
from openai.types.chat import ChatCompletion, ChatCompletionMessage, ToolCall, ToolCallFunction
6+
from openai.types.chat import ChatCompletion, ChatCompletionMessage
77
from openai.types.chat.chat_completion import Choice
8-
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk, ChoiceDelta
9-
from openai.types.chat.chat_completion_chunk import ToolCall as ChunkToolCall
10-
from openai.types.chat.chat_completion_chunk import ToolCallFunction as ChunkToolCallFunction
8+
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk, ChoiceDelta, ChoiceDeltaToolCall, ChoiceDeltaToolCallFunction
9+
from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall, Function
1110
from openai.types.completion_usage import CompletionUsage
1211
from openai.types.create_embedding_response import CreateEmbeddingResponse, Usage
1312
from openai.types.embedding import Embedding
@@ -107,10 +106,10 @@ def mock_openai_response_with_tool_calls():
107106
content="I'll check the weather for you.",
108107
role="assistant",
109108
tool_calls=[
110-
ToolCall(
109+
ChatCompletionMessageToolCall(
111110
id="call_abc123",
112111
type="function",
113-
function=ToolCallFunction(
112+
function=Function(
114113
name="get_weather",
115114
arguments='{"location": "San Francisco", "unit": "celsius"}',
116115
),
@@ -352,11 +351,11 @@ def test_streaming_with_tool_calls(mock_client):
352351
delta=ChoiceDelta(
353352
role="assistant",
354353
tool_calls=[
355-
ChunkToolCall(
354+
ChoiceDeltaToolCall(
356355
index=0,
357356
id="call_abc123",
358357
type="function",
359-
function=ChunkToolCallFunction(
358+
function=ChoiceDeltaToolCallFunction(
360359
name="get_weather",
361360
arguments='{"location": "',
362361
),
@@ -377,11 +376,11 @@ def test_streaming_with_tool_calls(mock_client):
377376
index=0,
378377
delta=ChoiceDelta(
379378
tool_calls=[
380-
ChunkToolCall(
379+
ChoiceDeltaToolCall(
381380
index=0,
382381
id="call_abc123",
383382
type="function",
384-
function=ChunkToolCallFunction(
383+
function=ChoiceDeltaToolCallFunction(
385384
arguments='San Francisco"',
386385
),
387386
)
@@ -401,11 +400,11 @@ def test_streaming_with_tool_calls(mock_client):
401400
index=0,
402401
delta=ChoiceDelta(
403402
tool_calls=[
404-
ChunkToolCall(
403+
ChoiceDeltaToolCall(
405404
index=0,
406405
id="call_abc123",
407406
type="function",
408-
function=ChunkToolCallFunction(
407+
function=ChoiceDeltaToolCallFunction(
409408
arguments=', "unit": "celsius"}',
410409
),
411410
)

0 commit comments

Comments
 (0)