From f4b0cf81c72748882354ad1c67b8e334522d7f01 Mon Sep 17 00:00:00 2001 From: Jari Bakken Date: Fri, 15 Mar 2024 00:52:11 +0100 Subject: [PATCH] community[patch]: bedrock: add model name to identifying params (cache keys) (#4758) * bedrock: add model name to identifying params (cache keys) * Fix test * Fix --------- Co-authored-by: jacoblee93 --- .../src/chat_models/bedrock/web.ts | 6 +++++ .../src/chat_models/tests/chatbedrock.test.ts | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 libs/langchain-community/src/chat_models/tests/chatbedrock.test.ts diff --git a/libs/langchain-community/src/chat_models/bedrock/web.ts b/libs/langchain-community/src/chat_models/bedrock/web.ts index ce3ca8170c63..bbf5e8b52727 100644 --- a/libs/langchain-community/src/chat_models/bedrock/web.ts +++ b/libs/langchain-community/src/chat_models/bedrock/web.ts @@ -153,6 +153,12 @@ export class BedrockChat extends BaseChatModel implements BaseBedrockInput { return { region: this.region }; } + _identifyingParams(): Record { + return { + model: this.model, + }; + } + _llmType() { return "bedrock"; } diff --git a/libs/langchain-community/src/chat_models/tests/chatbedrock.test.ts b/libs/langchain-community/src/chat_models/tests/chatbedrock.test.ts new file mode 100644 index 000000000000..df5d7c50ea67 --- /dev/null +++ b/libs/langchain-community/src/chat_models/tests/chatbedrock.test.ts @@ -0,0 +1,25 @@ +/* eslint-disable no-process-env */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import { BedrockChat } from "../bedrock/web.js"; + +test("Test Bedrock identifying params", async () => { + const region = "us-east-1"; + const model = "anthropic.claude-v2"; + + const bedrock = new BedrockChat({ + maxTokens: 20, + region, + model, + maxRetries: 0, + credentials: { + accessKeyId: "unused", + secretAccessKey: "unused", + sessionToken: "unused", + }, + }); + + expect(bedrock._identifyingParams()).toMatchObject({ + model, + }); +});