From e6fad4abe7eb6c24183e3693bf466ffd192cc6f9 Mon Sep 17 00:00:00 2001 From: Allen Firstenberg Date: Fri, 10 Jan 2025 17:07:18 -0500 Subject: [PATCH] fix(google-common): Search grounding formatting (#7471) --- .../src/output_parsers.ts | 9 +++++---- .../src/tests/output_parsers.test.ts | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libs/langchain-google-common/src/output_parsers.ts b/libs/langchain-google-common/src/output_parsers.ts index 8ca9377011ba..2c0d0d031022 100644 --- a/libs/langchain-google-common/src/output_parsers.ts +++ b/libs/langchain-google-common/src/output_parsers.ts @@ -23,9 +23,9 @@ export abstract class BaseGoogleSearchOutputParser extends BaseLLMOutputParser { ret = `${ret}${this.chunkToString(chunk, index)}\n`; }); diff --git a/libs/langchain-google-common/src/tests/output_parsers.test.ts b/libs/langchain-google-common/src/tests/output_parsers.test.ts index ac3c135f5279..f3be76f57456 100644 --- a/libs/langchain-google-common/src/tests/output_parsers.test.ts +++ b/libs/langchain-google-common/src/tests/output_parsers.test.ts @@ -214,4 +214,23 @@ describe("GoogleSearchOutputParsers", () => { expect(result).toEqual(expectation); }); + + test("non-grounded", async () => { + const record: Record = {}; + const projectId = mockId(); + const authOptions: MockClientAuthInfo = { + record, + projectId, + resultFile: "chat-1-mock.json", + }; + + const model = new ChatGoogle({ + authOptions, + modelName: "gemini-1.5-pro-002", + }); + const parser = new SimpleGoogleSearchOutputParser(); + const chain = model.pipe(parser); + const result = await chain.invoke("Flip a coin."); + expect(result).toEqual("T"); + }); });