Skip to content

Commit

Permalink
Keep stream_usage defaulting to true
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jun 21, 2024
1 parent 9d8de58 commit 22292f3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions libs/langchain-openai/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class ChatOpenAI<

streaming = false;

streamUsage = false;
streamUsage = true;

maxTokens?: number;

Expand Down Expand Up @@ -570,10 +570,7 @@ export class ChatOpenAI<
stop: options?.stop ?? this.stopSequences,
user: this.user,
// if include_usage is set or streamUsage then stream must be set to true.
stream:
options?.stream_options?.include_usage || this.streamUsage
? true
: this.streaming,
stream: this.streaming,
functions: options?.functions,
function_call: options?.function_call,
tools: isStructuredToolArray(options?.tools)
Expand All @@ -584,11 +581,9 @@ export class ChatOpenAI<
seed: options?.seed,
...(options?.stream_options !== undefined

Check failure on line 582 in libs/langchain-openai/src/chat_models.ts

View workflow job for this annotation

GitHub Actions / Check linting

Do not nest ternary expressions
? { stream_options: options.stream_options }
: {
stream_options: {
include_usage: this.streamUsage && this.streaming,
},
}),
: this.streamUsage && this.streaming
? { stream_options: { include_usage: true } }
: {}),
parallel_tool_calls: options?.parallel_tool_calls,
...this.modelKwargs,
};
Expand Down

0 comments on commit 22292f3

Please sign in to comment.