@@ -17,6 +17,7 @@ import { describe, expect, test, it } from "vitest";
1717import { convertToConverseMessages } from "../utils/message_inputs.js" ;
1818import { handleConverseStreamContentBlockDelta } from "../utils/message_outputs.js" ;
1919import { ChatBedrockConverse } from "../chat_models.js" ;
20+ import { load } from "@langchain/core/load" ;
2021
2122describe ( "convertToConverseMessages" , ( ) => {
2223 const testCases : {
@@ -666,3 +667,43 @@ describe("tool_choice works for supported models", () => {
666667 }
667668 ) ;
668669} ) ;
670+
671+ test ( "Test ChatBedrockConverse deserialization from model_id and region_name" , async ( ) => {
672+ delete process . env . AWS_ACCESS_KEY_ID ;
673+ delete process . env . AWS_SECRET_ACCESS_KEY ;
674+ delete process . env . AWS_DEFAULT_REGION ;
675+
676+ // Simulate a serialized ChatBedrockConverse with Python naming (model_id, region_name)
677+ // This matches the format that LangSmith Hub stores prompts with model configuration
678+ const serialized = JSON . stringify ( {
679+ lc : 1 ,
680+ type : "constructor" ,
681+ id : [
682+ "langchain" ,
683+ "chat_models" ,
684+ "chat_bedrock_converse" ,
685+ "ChatBedrockConverse" ,
686+ ] ,
687+ kwargs : {
688+ model_id : "anthropic.claude-3-sonnet-20240229-v1:0" ,
689+ region_name : "us-west-2" ,
690+ temperature : 0.7 ,
691+ credentials : {
692+ accessKeyId : "test-key" ,
693+ secretAccessKey : "test-secret" ,
694+ } ,
695+ } ,
696+ } ) ;
697+
698+ const loaded = await load < ChatBedrockConverse > ( serialized , {
699+ importMap : {
700+ chat_models__chat_bedrock_converse : { ChatBedrockConverse } ,
701+ } ,
702+ } ) ;
703+
704+ // Verify deserialization correctly maps model_id -> model and region_name -> region
705+ expect ( loaded ) . toBeInstanceOf ( ChatBedrockConverse ) ;
706+ expect ( loaded . model ) . toBe ( "anthropic.claude-3-sonnet-20240229-v1:0" ) ;
707+ expect ( loaded . region ) . toBe ( "us-west-2" ) ;
708+ expect ( loaded . temperature ) . toBe ( 0.7 ) ;
709+ } ) ;
0 commit comments