Skip to content

Commit

Permalink
fix(google): Fixed - TypeError: Cannot read properties of undefined (…
Browse files Browse the repository at this point in the history
…reading 'generationInfo') (#6756)
  • Loading branch information
pksharmapokhrel authored Sep 16, 2024
1 parent ee33e9f commit 68e53a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/langchain-google-common/src/utils/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,11 @@ export function getGeminiAPI(config?: GeminiAPIConfig) {
response: GoogleLLMResponse
): ChatGeneration[] {
const parts = responseToParts(response);

if (parts.length === 0) {
return [];
}

let ret = parts.map((part) => partToChatGeneration(part));
if (ret.every((item) => typeof item.message.content === "string")) {
const combinedContent = ret.map((item) => item.message.content).join("");
Expand Down

0 comments on commit 68e53a5

Please sign in to comment.