Skip to content

Commit

Permalink
simpler approach as per suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
pksharmapokhrel committed Sep 14, 2024
1 parent e16b049 commit bd42123
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/langchain-google-common/src/utils/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,13 @@ 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") && ret.length > 0) {
if (ret.every((item) => typeof item.message.content === "string")) {
const combinedContent = ret.map((item) => item.message.content).join("");
const combinedText = ret.map((item) => item.text).join("");
const toolCallChunks: ToolCallChunk[] | undefined = ret[
Expand Down

0 comments on commit bd42123

Please sign in to comment.