From e4095eec92279829f7f6be347fb1d37131c7b975 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Tue, 22 Oct 2024 11:07:02 +0530 Subject: [PATCH] chore: Include usage object in stream response of chat completion response by default --- src/providers/openai/chatComplete.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/providers/openai/chatComplete.ts b/src/providers/openai/chatComplete.ts index 89ac7bdd8..e5cad3902 100644 --- a/src/providers/openai/chatComplete.ts +++ b/src/providers/openai/chatComplete.ts @@ -45,10 +45,19 @@ export const OpenAIChatCompleteConfig: ProviderConfig = { param: 'n', default: 1, }, - stream: { - param: 'stream', - default: false, - }, + stream: [ + { + param: 'stream', + default: false, + }, + { + param: 'stream_options', + transform: (params: Params) => { + if (params.stream_options) params.stream_options; + if (params.stream) return { include_usage: true }; + }, + }, + ], stop: { param: 'stop', },