File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
posthog/ai/providers/openai Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,10 @@ def _create_streaming(
8181 start_time = time .time ()
8282 usage_stats : Dict [str , int ] = {}
8383 accumulated_content = []
84- stream_options = {"include_usage" : True }
85- response = self ._client .chat .completions .create (** kwargs , stream_options = stream_options )
84+ if "stream_options" not in kwargs :
85+ kwargs ["stream_options" ] = {}
86+ kwargs ["stream_options" ]["include_usage" ] = True
87+ response = super ().create (** kwargs )
8688
8789 def generator ():
8890 nonlocal usage_stats
Original file line number Diff line number Diff line change @@ -82,8 +82,10 @@ async def _create_streaming(
8282 start_time = time .time ()
8383 usage_stats : Dict [str , int ] = {}
8484 accumulated_content = []
85- stream_options = {"include_usage" : True }
86- response = await self ._client .chat .completions .create (** kwargs , stream_options = stream_options )
85+ if "stream_options" not in kwargs :
86+ kwargs ["stream_options" ] = {}
87+ kwargs ["stream_options" ]["include_usage" ] = True
88+ response = await super ().create (** kwargs )
8789
8890 async def async_generator ():
8991 nonlocal usage_stats , accumulated_content
You can’t perform that action at this time.
0 commit comments