Skip to content

Commit

Permalink
feat(langchain): Add DeepSeek to initChatModel (#7609)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Jan 28, 2025
1 parent 74f89e6 commit 184b34b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
"@langchain/cerebras": "*",
"@langchain/cohere": "*",
"@langchain/core": "workspace:*",
"@langchain/deepseek": "*",
"@langchain/google-genai": "*",
"@langchain/google-vertexai": "*",
"@langchain/google-vertexai-web": "*",
Expand Down Expand Up @@ -469,6 +470,7 @@
"@langchain/cerebras": "*",
"@langchain/cohere": "*",
"@langchain/core": ">=0.2.21 <0.4.0",
"@langchain/deepseek": "*",
"@langchain/google-genai": "*",
"@langchain/google-vertexai": "*",
"@langchain/google-vertexai-web": "*",
Expand All @@ -494,6 +496,9 @@
"@langchain/cohere": {
"optional": true
},
"@langchain/deepseek": {
"optional": true
},
"@langchain/google-genai": {
"optional": true
},
Expand Down
11 changes: 11 additions & 0 deletions langchain/src/chat_models/tests/universal.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,17 @@ describe("Works with all model providers", () => {
expect(vertexAIWebResult).toBeDefined();
expect(vertexAIWebResult.content.length).toBeGreaterThan(0);
});

it("Can invoke deepseek", async () => {
const deepSeek = await initChatModel("deepseek-chat", {
modelProvider: "deepseek",
temperature: 0,
});

const deepSeekResult = await deepSeek.invoke("what's your name");
expect(deepSeekResult).toBeDefined();
expect(deepSeekResult.content.length).toBeGreaterThan(0);
});
});

test("Is compatible with agents", async () => {
Expand Down
7 changes: 7 additions & 0 deletions langchain/src/chat_models/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const _SUPPORTED_PROVIDERS = [
"mistralai",
"groq",
"bedrock",
"cerebras",
"deepseek",
] as const;

export type ChatModelProvider = (typeof _SUPPORTED_PROVIDERS)[number];
Expand Down Expand Up @@ -130,6 +132,10 @@ async function _initChatModelHelper(
const { ChatBedrockConverse } = await import("@langchain/aws");
return new ChatBedrockConverse({ model, ...passedParams });
}
case "deepseek": {
const { ChatDeepSeek } = await import("@langchain/deepseek");
return new ChatDeepSeek({ model, ...passedParams });
}
case "fireworks": {
const { ChatFireworks } = await import(
// We can not 'expect-error' because if you explicitly build `@langchain/community`
Expand Down Expand Up @@ -611,6 +617,7 @@ export async function initChatModel<
* - groq (@langchain/groq)
* - ollama (@langchain/ollama)
* - cerebras (@langchain/cerebras)
* - deepseek (@langchain/deepseek)
* @param {string[] | "any"} [fields.configurableFields] - Which model parameters are configurable:
* - undefined: No configurable fields.
* - "any": All fields are configurable. (See Security Note in description)
Expand Down
6 changes: 5 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12465,7 +12465,7 @@ __metadata:
languageName: unknown
linkType: soft

"@langchain/deepseek@workspace:*, @langchain/deepseek@workspace:libs/langchain-deepseek":
"@langchain/deepseek@*, @langchain/deepseek@workspace:*, @langchain/deepseek@workspace:libs/langchain-deepseek":
version: 0.0.0-use.local
resolution: "@langchain/deepseek@workspace:libs/langchain-deepseek"
dependencies:
Expand Down Expand Up @@ -33477,6 +33477,7 @@ __metadata:
"@langchain/cerebras": "*"
"@langchain/cohere": "*"
"@langchain/core": "workspace:*"
"@langchain/deepseek": "*"
"@langchain/google-genai": "*"
"@langchain/google-vertexai": "*"
"@langchain/google-vertexai-web": "*"
Expand Down Expand Up @@ -33537,6 +33538,7 @@ __metadata:
"@langchain/cerebras": "*"
"@langchain/cohere": "*"
"@langchain/core": ">=0.2.21 <0.4.0"
"@langchain/deepseek": "*"
"@langchain/google-genai": "*"
"@langchain/google-vertexai": "*"
"@langchain/google-vertexai-web": "*"
Expand All @@ -33557,6 +33559,8 @@ __metadata:
optional: true
"@langchain/cohere":
optional: true
"@langchain/deepseek":
optional: true
"@langchain/google-genai":
optional: true
"@langchain/google-vertexai":
Expand Down

0 comments on commit 184b34b

Please sign in to comment.