@@ -308,9 +308,12 @@ export function createDescribeEvent(props: {
308308/* -----------------------------------------------------------
309309 API REQUESTS
310310----------------------------------------------------------- */
311- export function createRequestEvent ( props : {
311+ export function createRequestEvent < Stream extends boolean > ( props : {
312312 source : AgenticaEventSource ;
313- body : OpenAI . ChatCompletionCreateParamsStreaming | OpenAI . ChatCompletionCreateParamsNonStreaming ;
313+ stream : Stream ;
314+ body : Stream extends true
315+ ? OpenAI . ChatCompletionCreateParamsStreaming
316+ : OpenAI . ChatCompletionCreateParamsNonStreaming ;
314317 options ?: OpenAI . RequestOptions | undefined ;
315318} ) : AgenticaRequestEvent {
316319 const id : string = v4 ( ) ;
@@ -320,17 +323,23 @@ export function createRequestEvent(props: {
320323 id,
321324 created_at,
322325 source : props . source ,
323- body : props . body ,
326+ stream : props . stream as false ,
327+ body : props . body as OpenAI . ChatCompletionCreateParamsNonStreaming ,
324328 options : props . options ,
325329 } ;
326330}
327331
328- export function createResponseEvent ( props : {
332+ export function createResponseEvent < Stream extends boolean > ( props : {
329333 request_id : string ;
330334 source : AgenticaEventSource ;
331- body : OpenAI . ChatCompletionCreateParamsStreaming ;
335+ stream : Stream ;
336+ body : Stream extends true
337+ ? OpenAI . ChatCompletionCreateParamsStreaming
338+ : OpenAI . ChatCompletionCreateParamsNonStreaming ;
332339 options ?: OpenAI . RequestOptions | undefined ;
333- response : AgenticaResponseEvent . Response ;
340+ completion : Stream extends true
341+ ? AsyncGenerator < OpenAI . ChatCompletionChunk , undefined , undefined >
342+ : OpenAI . ChatCompletion ;
334343 join : ( ) => Promise < OpenAI . ChatCompletion > ;
335344} ) : AgenticaResponseEvent {
336345 const id : string = v4 ( ) ;
@@ -341,9 +350,10 @@ export function createResponseEvent(props: {
341350 request_id : props . request_id ,
342351 created_at,
343352 source : props . source ,
344- body : props . body ,
353+ stream : props . stream as false ,
354+ body : props . body as OpenAI . ChatCompletionCreateParamsNonStreaming ,
355+ completion : props . completion as OpenAI . ChatCompletion ,
345356 options : props . options ,
346- response : props . response ,
347357 join : props . join ,
348358 } ;
349359}
0 commit comments