Skip to content

Commit

Permalink
Fix undefined dereference. Issue langchain-ai#7171
Browse files Browse the repository at this point in the history
  • Loading branch information
afirstenberg committed Nov 7, 2024
1 parent d75e3ee commit 4f02f0a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/langchain-google-common/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ export abstract class ChatGoogleBase<AuthOptions>
runManager
);
const ret = this.connection.api.responseToChatResult(response);
await runManager?.handleLLMNewToken(ret.generations[0].text);
const chunk = ret?.generations?.[0];
if (chunk) {
await runManager?.handleLLMNewToken(chunk.text || "");
}
return ret;
}

Expand Down

0 comments on commit 4f02f0a

Please sign in to comment.