@@ -19,6 +19,7 @@ export interface RunOptions {
19
19
threadId ?: string ;
20
20
rawResponse ?: boolean ;
21
21
runTools ?: boolean ;
22
+ name ?: string ; // Pipe name for SDK
22
23
}
23
24
24
25
export interface RunOptionsStream extends RunOptions {
@@ -162,6 +163,7 @@ export class Pipe {
162
163
private async handleStreamResponse (
163
164
options : RunOptionsStream ,
164
165
response : RunResponseStream ,
166
+ pipeName : string ,
165
167
) : Promise < RunResponseStream > {
166
168
const endpoint = '/v1/pipes/run' ;
167
169
const stream = this . isStreamRequested ( options ) ;
@@ -216,6 +218,7 @@ export class Pipe {
216
218
messages,
217
219
threadId : currentResponse . threadId ,
218
220
} ,
221
+ pipeName
219
222
) ;
220
223
221
224
callCount ++ ;
@@ -244,6 +247,7 @@ export class Pipe {
244
247
const modelProvider = getProvider ( providerString ) ;
245
248
const isAnthropic = modelProvider === ANTHROPIC ;
246
249
const hasTools = this . pipe . tools . length > 0 ;
250
+ const pipeName = options . name || this . pipe . name ;
247
251
248
252
let stream = this . isStreamRequested ( options ) ;
249
253
@@ -260,7 +264,7 @@ export class Pipe {
260
264
261
265
let response = await this . createRequest <
262
266
RunResponse | RunResponseStream
263
- > ( endpoint , body ) ;
267
+ > ( endpoint , body , pipeName ) ;
264
268
if ( Object . entries ( response ) . length === 0 ) {
265
269
return { } as RunResponse | RunResponseStream ;
266
270
}
@@ -277,6 +281,7 @@ export class Pipe {
277
281
return await this . handleStreamResponse (
278
282
options as RunOptionsStream ,
279
283
response as RunResponseStream ,
284
+ pipeName
280
285
) ;
281
286
}
282
287
@@ -319,7 +324,7 @@ export class Pipe {
319
324
messages,
320
325
stream : false ,
321
326
threadId : currentResponse . threadId ,
322
- } ) ;
327
+ } , pipeName ) ;
323
328
324
329
callCount ++ ;
325
330
@@ -338,17 +343,22 @@ export class Pipe {
338
343
return currentResponse ;
339
344
}
340
345
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 > {
342
351
const isProdEnv = this . prod ;
343
352
const prodOptions = {
344
353
endpoint,
345
354
body : {
346
355
...body ,
347
- name : this . pipe . name ,
356
+ name : pipeName || this . pipe . name ,
348
357
} ,
349
358
} ;
350
359
351
360
let localOptions = { } as any ;
361
+
352
362
if ( ! isProdEnv ) {
353
363
const providerString = this . pipe . model . split ( ':' ) [ 0 ] ;
354
364
const modelProvider = getProvider ( providerString ) ;
@@ -360,9 +370,7 @@ export class Pipe {
360
370
llmApiKey : getLLMApiKey ( modelProvider ) ,
361
371
} ,
362
372
} ;
363
- }
364
373
365
- if ( ! isProdEnv ) {
366
374
const isServerRunning = await isLocalServerRunning ( ) ;
367
375
if ( ! isServerRunning ) return { } as T ;
368
376
}
0 commit comments