Skip to content

Commit

Permalink
community[patch]: bedrock: add model name to identifying params (cach…
Browse files Browse the repository at this point in the history
…e keys) (#4758)

* bedrock: add model name to identifying params (cache keys)

* Fix test

* Fix

---------

Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
jarib and jacoblee93 authored Mar 14, 2024
1 parent 5af48bc commit f4b0cf8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libs/langchain-community/src/chat_models/bedrock/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export class BedrockChat extends BaseChatModel implements BaseBedrockInput {
return { region: this.region };
}

_identifyingParams(): Record<string, string> {
return {
model: this.model,
};
}

_llmType() {
return "bedrock";
}
Expand Down
25 changes: 25 additions & 0 deletions libs/langchain-community/src/chat_models/tests/chatbedrock.test.ts
Original file line number Diff line number Diff line change
@@ -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,
});
});

0 comments on commit f4b0cf8

Please sign in to comment.