openai stream include_usage=true
This commit is contained in:
parent
261d181362
commit
cbbebe276b
2 changed files with 6 additions and 0 deletions
|
|
@ -35,6 +35,11 @@ export class OpenAIApi implements BaseLlmApi {
|
|||
});
|
||||
}
|
||||
modifyChatBody<T extends ChatCompletionCreateParams>(body: T): T {
|
||||
// Add stream_options to include usage in streaming responses
|
||||
if (body.stream) {
|
||||
(body as any).stream_options = { include_usage: true };
|
||||
}
|
||||
|
||||
// o-series models - only apply for official OpenAI API
|
||||
const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/";
|
||||
if (isOfficialOpenAIAPI) {
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ export const createAdapterTests = (testConfig: AdapterTestConfig) => {
|
|||
model: "gpt-4",
|
||||
messages: [{ role: "user", content: "hello" }],
|
||||
stream: true,
|
||||
stream_options: { include_usage: true },
|
||||
...testConfig.customBodyOptions,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue