Skip to content

Commit

Permalink
groq[patch]: Add streaming class prop (#4573)
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored Feb 28, 2024
1 parent 1ab880f commit 2e01eda
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libs/langchain-groq/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ChatGroqInput extends BaseChatModelParams {
/**
* Whether or not to stream responses.
*/
stream?: boolean;
streaming?: boolean;
/**
* The temperature to use for sampling.
* @default 0.7
Expand Down Expand Up @@ -161,6 +161,8 @@ export class ChatGroq extends BaseChatModel<ChatGroqCallOptions> {

temperature = 0.7;

streaming = false;

static lc_name() {
return "ChatGroq";
}
Expand Down Expand Up @@ -193,6 +195,7 @@ export class ChatGroq extends BaseChatModel<ChatGroqCallOptions> {
});
this.temperature = fields?.temperature ?? this.temperature;
this.modelName = fields?.modelName ?? this.modelName;
this.streaming = fields?.streaming ?? this.streaming;
}

async completionWithRetry(
Expand Down Expand Up @@ -269,7 +272,7 @@ export class ChatGroq extends BaseChatModel<ChatGroqCallOptions> {
const params = this.invocationParams(options);
const messagesMapped = convertMessagesToGroqParams(messages);

if (params.stream) {
if (this.streaming) {
const stream = this._streamResponseChunks(messages, options, runManager);
const finalChunks: Record<number, ChatGenerationChunk> = {};
for await (const chunk of stream) {
Expand Down

0 comments on commit 2e01eda

Please sign in to comment.