Skip to content

Commit

Permalink
Only set stream_options if the model is OpenAI
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed May 28, 2024
1 parent 1734e47 commit 4a06ed4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libs/langchain-openai/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ export class ChatOpenAI<
)
);
}
const llmType = this._llmType();

const params: Omit<
OpenAIClient.Chat.ChatCompletionCreateParams,
"messages"
Expand All @@ -553,9 +555,14 @@ export class ChatOpenAI<
tool_choice: options?.tool_choice,
response_format: options?.response_format,
seed: options?.seed,
stream_options: {
include_usage: true,
},
// Only set stream_options if the model is OpenAI
...(llmType === "openai"
? {
stream_options: {
include_usage: true,
},
}
: {}),
...this.modelKwargs,
};
return params;
Expand Down

0 comments on commit 4a06ed4

Please sign in to comment.