@@ -19,6 +19,7 @@ export interface RunOptions {
1919 threadId ?: string ;
2020 rawResponse ?: boolean ;
2121 runTools ?: boolean ;
22+ name ?: string ; // Pipe name for SDK
2223}
2324
2425export interface RunOptionsStream extends RunOptions {
@@ -162,6 +163,7 @@ export class Pipe {
162163 private async handleStreamResponse (
163164 options : RunOptionsStream ,
164165 response : RunResponseStream ,
166+ pipeName : string ,
165167 ) : Promise < RunResponseStream > {
166168 const endpoint = '/v1/pipes/run' ;
167169 const stream = this . isStreamRequested ( options ) ;
@@ -216,6 +218,7 @@ export class Pipe {
216218 messages,
217219 threadId : currentResponse . threadId ,
218220 } ,
221+ pipeName
219222 ) ;
220223
221224 callCount ++ ;
@@ -244,6 +247,7 @@ export class Pipe {
244247 const modelProvider = getProvider ( providerString ) ;
245248 const isAnthropic = modelProvider === ANTHROPIC ;
246249 const hasTools = this . pipe . tools . length > 0 ;
250+ const pipeName = options . name || this . pipe . name ;
247251
248252 let stream = this . isStreamRequested ( options ) ;
249253
@@ -260,7 +264,7 @@ export class Pipe {
260264
261265 let response = await this . createRequest <
262266 RunResponse | RunResponseStream
263- > ( endpoint , body ) ;
267+ > ( endpoint , body , pipeName ) ;
264268 if ( Object . entries ( response ) . length === 0 ) {
265269 return { } as RunResponse | RunResponseStream ;
266270 }
@@ -277,6 +281,7 @@ export class Pipe {
277281 return await this . handleStreamResponse (
278282 options as RunOptionsStream ,
279283 response as RunResponseStream ,
284+ pipeName
280285 ) ;
281286 }
282287
@@ -319,7 +324,7 @@ export class Pipe {
319324 messages,
320325 stream : false ,
321326 threadId : currentResponse . threadId ,
322- } ) ;
327+ } , pipeName ) ;
323328
324329 callCount ++ ;
325330
@@ -338,17 +343,22 @@ export class Pipe {
338343 return currentResponse ;
339344 }
340345
341- private async createRequest < T > ( endpoint : string , body : any ) : Promise < T > {
346+ private async createRequest < T > (
347+ endpoint : string ,
348+ body : any ,
349+ pipeName ?: string ,
350+ ) : Promise < T > {
342351 const isProdEnv = this . prod ;
343352 const prodOptions = {
344353 endpoint,
345354 body : {
346355 ...body ,
347- name : this . pipe . name ,
356+ name : pipeName || this . pipe . name ,
348357 } ,
349358 } ;
350359
351360 let localOptions = { } as any ;
361+
352362 if ( ! isProdEnv ) {
353363 const providerString = this . pipe . model . split ( ':' ) [ 0 ] ;
354364 const modelProvider = getProvider ( providerString ) ;
@@ -360,9 +370,7 @@ export class Pipe {
360370 llmApiKey : getLLMApiKey ( modelProvider ) ,
361371 } ,
362372 } ;
363- }
364373
365- if ( ! isProdEnv ) {
366374 const isServerRunning = await isLocalServerRunning ( ) ;
367375 if ( ! isServerRunning ) return { } as T ;
368376 }
0 commit comments