Skip to content

Commit 68e53a5

Browse files
authoredSep 16, 2024··
fix(google): Fixed - TypeError: Cannot read properties of undefined (reading 'generationInfo') (#6756)
1 parent ee33e9f commit 68e53a5

File tree

1 file changed

+5
-0
lines changed
  • libs/langchain-google-common/src/utils

1 file changed

+5
-0
lines changed
 

‎libs/langchain-google-common/src/utils/gemini.ts

+5
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,11 @@ export function getGeminiAPI(config?: GeminiAPIConfig) {
624624
response: GoogleLLMResponse
625625
): ChatGeneration[] {
626626
const parts = responseToParts(response);
627+
628+
if (parts.length === 0) {
629+
return [];
630+
}
631+
627632
let ret = parts.map((part) => partToChatGeneration(part));
628633
if (ret.every((item) => typeof item.message.content === "string")) {
629634
const combinedContent = ret.map((item) => item.message.content).join("");

0 commit comments

Comments
 (0)
Please sign in to comment.