Skip to content

Commit 2cfd76c

Browse files
committed
Add 'Include stream options' checkbox for OpenAI-compatible providers
1 parent 156cab8 commit 2cfd76c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/api/providers/openai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class OpenAiHandler implements ApiHandler {
4545
stream: true,
4646
}
4747

48-
if (this.options.includeStreamOptions) {
48+
if (this.options.includeStreamOptions ?? true) {
4949
requestOptions.stream_options = { include_usage: true }
5050
}
5151

src/shared/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface ApiHandlerOptions {
3535
azureApiVersion?: string
3636
openRouterUseMiddleOutTransform?: boolean
3737
includeStreamOptions?: boolean
38+
setAzureApiVersion?: boolean
3839
}
3940

4041
export type ApiConfiguration = ApiHandlerOptions & {

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,24 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage }:
445445
placeholder={"Enter Model ID..."}>
446446
<span style={{ fontWeight: 500 }}>Model ID</span>
447447
</VSCodeTextField>
448+
<div style={{ display: 'flex', alignItems: 'center' }}>
449+
<VSCodeCheckbox
450+
checked={apiConfiguration?.includeStreamOptions ?? true}
451+
onChange={(e: any) => {
452+
const isChecked = e.target.checked
453+
setApiConfiguration({
454+
...apiConfiguration,
455+
includeStreamOptions: isChecked
456+
})
457+
}}>
458+
Include stream options
459+
</VSCodeCheckbox>
460+
<span
461+
className="codicon codicon-info"
462+
title="Stream options are for { include_usage: true }. Some providers may not support this option."
463+
style={{ marginLeft: '5px', cursor: 'help' }}
464+
></span>
465+
</div>
448466
<VSCodeCheckbox
449467
checked={azureApiVersionSelected}
450468
onChange={(e: any) => {

0 commit comments

Comments
 (0)