Skip to content

Commit d60f40f

Browse files
authored
fix(langchain): infer mistral in initChatModel (langchain-ai#8966)
1 parent 8343f07 commit d60f40f

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

.changeset/wet-bikes-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"langchain": patch
3+
---
4+
5+
infer mistralai models

langchain/src/chat_models/tests/universal.int.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,3 +814,20 @@ describe("Serialization", () => {
814814
);
815815
});
816816
});
817+
818+
// https://github.com/langchain-ai/langchainjs/issues/8962
819+
describe("Can be initialized without `modelProvider`", () => {
820+
test.each([
821+
["openai", "gpt-4o-mini"],
822+
["anthropic", "claude-3-5-sonnet-20240620"],
823+
["mistralai", "mistral-large-latest"],
824+
])("for %s", async (_, modelName) => {
825+
const model = await initChatModel(modelName, {
826+
temperature: 0,
827+
});
828+
829+
const modelResult = await model.invoke("what's your name");
830+
expect(modelResult).toBeDefined();
831+
expect(modelResult.content.length).toBeGreaterThan(0);
832+
});
833+
});

langchain/src/chat_models/universal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ export function _inferModelProvider(modelName: string): string | undefined {
218218
return "google-vertexai";
219219
} else if (modelName.startsWith("amazon.")) {
220220
return "bedrock";
221+
} else if (modelName.startsWith("mistral")) {
222+
return "mistralai";
221223
} else {
222224
return undefined;
223225
}

0 commit comments

Comments
 (0)