Skip to content

Commit e7052e0

Browse files
committed
update
1 parent 82dbd59 commit e7052e0

File tree

3 files changed

+203
-254
lines changed

3 files changed

+203
-254
lines changed

camel/models/openai_model.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Optional,
2626
Type,
2727
Union,
28+
cast,
2829
)
2930

3031
from openai import AsyncOpenAI, AsyncStream, OpenAI, Stream
@@ -342,8 +343,11 @@ def _run(
342343
if response_format:
343344
if is_streaming:
344345
if self._api_mode == "responses":
345-
return self._request_responses_stream(
346-
messages, response_format, tools
346+
return cast(
347+
Stream[ChatCompletionChunk],
348+
self._request_responses_stream(
349+
messages, response_format, tools
350+
),
347351
)
348352
return self._request_stream_parse(
349353
messages, response_format, tools
@@ -355,10 +359,12 @@ def _run(
355359
)
356360
return self._request_parse(messages, response_format, tools)
357361
else:
362+
result: Union[ChatCompletion, Stream[ChatCompletionChunk]]
358363
if self._api_mode == "responses":
359364
if is_streaming:
360-
result = self._request_responses_stream(
361-
messages, None, tools
365+
result = cast(
366+
Stream[ChatCompletionChunk],
367+
self._request_responses_stream(messages, None, tools),
362368
)
363369
else:
364370
result = self._request_responses(messages, None, tools)
@@ -409,8 +415,11 @@ async def _arun(
409415
if response_format:
410416
if is_streaming:
411417
if self._api_mode == "responses":
412-
return await self._arequest_responses_stream(
413-
messages, response_format, tools
418+
return cast(
419+
AsyncStream[ChatCompletionChunk],
420+
await self._arequest_responses_stream(
421+
messages, response_format, tools
422+
),
414423
)
415424
return await self._arequest_stream_parse(
416425
messages, response_format, tools
@@ -424,10 +433,17 @@ async def _arun(
424433
messages, response_format, tools
425434
)
426435
else:
436+
result: Union[
437+
ChatCompletion,
438+
AsyncStream[ChatCompletionChunk],
439+
]
427440
if self._api_mode == "responses":
428441
if is_streaming:
429-
result = await self._arequest_responses_stream(
430-
messages, None, tools
442+
result = cast(
443+
AsyncStream[ChatCompletionChunk],
444+
await self._arequest_responses_stream(
445+
messages, None, tools
446+
),
431447
)
432448
else:
433449
result = await self._arequest_responses(

0 commit comments

Comments
 (0)