@@ -22,7 +22,7 @@ export interface RunOptions {
2222}
2323
2424export interface RunOptionsStream extends RunOptions {
25- stream : true ;
25+ stream : boolean ;
2626}
2727
2828export interface Usage {
@@ -56,6 +56,7 @@ export interface RunResponseStream {
5656
5757export interface PipeOptions extends PipeI {
5858 maxCalls ?: number ;
59+ prod ?: boolean ;
5960}
6061
6162interface ChoiceGenerate {
@@ -80,11 +81,16 @@ export class Pipe {
8081 private tools : Record < string , ( ...args : any [ ] ) => Promise < any > > ;
8182 private maxCalls : number ;
8283 private hasTools : boolean ;
84+ private prod : boolean ;
8385
8486 constructor ( options : PipeOptions ) {
85- const baseUrl = getApiUrl ( ) ;
87+ this . prod = options . prod ?? isProd ( ) ;
88+ const baseUrl = getApiUrl ( this . prod ) ;
89+
8690 this . request = new Request ( { apiKey : options . apiKey , baseUrl} ) ;
8791 this . pipe = options ;
92+
93+ delete this . pipe . prod ;
8894 delete this . pipe . apiKey ;
8995
9096 this . tools = this . getToolsFromPipe ( this . pipe ) ;
@@ -136,7 +142,7 @@ export class Pipe {
136142 responseMessage : Message ,
137143 toolResults : Message [ ] ,
138144 ) : Message [ ] {
139- return isProd ( )
145+ return this . prod
140146 ? toolResults
141147 : [ ...messages , responseMessage , ...toolResults ] ;
142148 }
@@ -260,6 +266,10 @@ export class Pipe {
260266 }
261267
262268 if ( ! runTools ) {
269+ if ( ! stream ) {
270+ return response as RunResponse ;
271+ }
272+
263273 return response as RunResponseStream ;
264274 }
265275
@@ -347,7 +357,8 @@ export class Pipe {
347357 } ,
348358 } ;
349359
350- const isProdEnv = isProd ( ) ;
360+ const isProdEnv = this . prod ;
361+
351362 if ( ! isProdEnv ) {
352363 const isServerRunning = await isLocalServerRunning ( ) ;
353364 if ( ! isServerRunning ) return { } as T ;
0 commit comments