99 MessageDelta ,
1010 MessageContent ,
1111} from '../resources/beta/threads/messages' ;
12- import * as Core from '../core' ;
13- import { RequestOptions } from '../core' ;
12+ import { RequestOptions } from '../internal/request-options' ;
1413import {
1514 Run ,
1615 RunCreateParamsBase ,
@@ -19,7 +18,7 @@ import {
1918 RunSubmitToolOutputsParamsBase ,
2019 RunSubmitToolOutputsParamsStreaming ,
2120} from '../resources/beta/threads/runs/runs' ;
22- import { type ReadableStream } from '../_shims/index ' ;
21+ import { type ReadableStream } from '../internal/shim-types ' ;
2322import { Stream } from '../streaming' ;
2423import { APIUserAbortError , OpenAIError } from '../error' ;
2524import {
@@ -31,6 +30,7 @@ import {
3130import { RunStep , RunStepDelta , ToolCall , ToolCallDelta } from '../resources/beta/threads/runs/steps' ;
3231import { ThreadCreateAndRunParamsBase , Threads } from '../resources/beta/threads/threads' ;
3332import { BaseEvents , EventStream } from './EventStream' ;
33+ import { isObj } from '../internal/utils' ;
3434
3535export interface AssistantStreamEvents extends BaseEvents {
3636 run : ( run : Run ) => void ;
@@ -163,7 +163,7 @@ export class AssistantStream
163163
164164 protected async _fromReadableStream (
165165 readableStream : ReadableStream ,
166- options ?: Core . RequestOptions ,
166+ options ?: RequestOptions ,
167167 ) : Promise < Run > {
168168 const signal = options ?. signal ;
169169 if ( signal ) {
@@ -187,15 +187,14 @@ export class AssistantStream
187187 }
188188
189189 static createToolAssistantStream (
190- threadId : string ,
191190 runId : string ,
192191 runs : Runs ,
193192 params : RunSubmitToolOutputsParamsStream ,
194193 options : RequestOptions | undefined ,
195194 ) : AssistantStream {
196195 const runner = new AssistantStream ( ) ;
197196 runner . _run ( ( ) =>
198- runner . _runToolAssistantStream ( threadId , runId , runs , params , {
197+ runner . _runToolAssistantStream ( runId , runs , params , {
199198 ...options ,
200199 headers : { ...options ?. headers , 'X-Stainless-Helper-Method' : 'stream' } ,
201200 } ) ,
@@ -205,10 +204,9 @@ export class AssistantStream
205204
206205 protected async _createToolAssistantStream (
207206 run : Runs ,
208- threadId : string ,
209207 runId : string ,
210208 params : RunSubmitToolOutputsParamsStream ,
211- options ?: Core . RequestOptions ,
209+ options ?: RequestOptions ,
212210 ) : Promise < Run > {
213211 const signal = options ?. signal ;
214212 if ( signal ) {
@@ -217,7 +215,7 @@ export class AssistantStream
217215 }
218216
219217 const body : RunSubmitToolOutputsParamsStreaming = { ...params , stream : true } ;
220- const stream = await run . submitToolOutputs ( threadId , runId , body , {
218+ const stream = await run . submitToolOutputs ( runId , body , {
221219 ...options ,
222220 signal : this . controller . signal ,
223221 } ) ;
@@ -303,7 +301,7 @@ export class AssistantStream
303301 protected async _createThreadAssistantStream (
304302 thread : Threads ,
305303 params : ThreadCreateAndRunParamsBase ,
306- options ?: Core . RequestOptions ,
304+ options ?: RequestOptions ,
307305 ) : Promise < Run > {
308306 const signal = options ?. signal ;
309307 if ( signal ) {
@@ -330,7 +328,7 @@ export class AssistantStream
330328 run : Runs ,
331329 threadId : string ,
332330 params : RunCreateParamsBase ,
333- options ?: Core . RequestOptions ,
331+ options ?: RequestOptions ,
334332 ) : Promise < Run > {
335333 const signal = options ?. signal ;
336334 if ( signal ) {
@@ -676,7 +674,7 @@ export class AssistantStream
676674 accValue += deltaValue ;
677675 } else if ( typeof accValue === 'number' && typeof deltaValue === 'number' ) {
678676 accValue += deltaValue ;
679- } else if ( Core . isObj ( accValue ) && Core . isObj ( deltaValue ) ) {
677+ } else if ( isObj ( accValue ) && isObj ( deltaValue ) ) {
680678 accValue = this . accumulateDelta ( accValue as Record < string , any > , deltaValue as Record < string , any > ) ;
681679 } else if ( Array . isArray ( accValue ) && Array . isArray ( deltaValue ) ) {
682680 if ( accValue . every ( ( x ) => typeof x === 'string' || typeof x === 'number' ) ) {
@@ -685,7 +683,7 @@ export class AssistantStream
685683 }
686684
687685 for ( const deltaEntry of deltaValue ) {
688- if ( ! Core . isObj ( deltaEntry ) ) {
686+ if ( ! isObj ( deltaEntry ) ) {
689687 throw new Error ( `Expected array delta entry to be an object but got: ${ deltaEntry } ` ) ;
690688 }
691689
@@ -748,7 +746,7 @@ export class AssistantStream
748746 protected async _threadAssistantStream (
749747 params : ThreadCreateAndRunParamsBase ,
750748 thread : Threads ,
751- options ?: Core . RequestOptions ,
749+ options ?: RequestOptions ,
752750 ) : Promise < Run > {
753751 return await this . _createThreadAssistantStream ( thread , params , options ) ;
754752 }
@@ -757,18 +755,17 @@ export class AssistantStream
757755 threadId : string ,
758756 runs : Runs ,
759757 params : RunCreateParamsBase ,
760- options ?: Core . RequestOptions ,
758+ options ?: RequestOptions ,
761759 ) : Promise < Run > {
762760 return await this . _createAssistantStream ( runs , threadId , params , options ) ;
763761 }
764762
765763 protected async _runToolAssistantStream (
766- threadId : string ,
767764 runId : string ,
768765 runs : Runs ,
769766 params : RunSubmitToolOutputsParamsStream ,
770- options ?: Core . RequestOptions ,
767+ options ?: RequestOptions ,
771768 ) : Promise < Run > {
772- return await this . _createToolAssistantStream ( runs , threadId , runId , params , options ) ;
769+ return await this . _createToolAssistantStream ( runs , runId , params , options ) ;
773770 }
774771}
0 commit comments