@langchain/deepseek 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @langchain/deepseek
2
2
 
3
+ ## 1.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#10078](https://github.com/langchain-ai/langchainjs/pull/10078) [`7be50a7`](https://github.com/langchain-ai/langchainjs/commit/7be50a7014d7622e0ab8d303dfc9c633ebc96333) Thanks [@christian-bromann](https://github.com/christian-bromann)! - chore(\*): update model profiles
8
+
9
+ - Updated dependencies [[`05396f7`](https://github.com/langchain-ai/langchainjs/commit/05396f7ce0a91c49a3bae4bbcd3dbdd6cbd18089), [`5a6f26b`](https://github.com/langchain-ai/langchainjs/commit/5a6f26bbaed80195dc538c538b96219a8b03f38f), [`7be50a7`](https://github.com/langchain-ai/langchainjs/commit/7be50a7014d7622e0ab8d303dfc9c633ebc96333)]:
10
+ - @langchain/openai@1.2.8
11
+
3
12
  ## 1.0.11
4
13
 
5
14
  ### Patch Changes
@@ -1,9 +1,8 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
1
  const require_profiles = require('./profiles.cjs');
3
- const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
4
- const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env"));
5
- const __langchain_openai = require_rolldown_runtime.__toESM(require("@langchain/openai"));
6
- const __langchain_core_outputs = require_rolldown_runtime.__toESM(require("@langchain/core/outputs"));
2
+ let _langchain_core_messages = require("@langchain/core/messages");
3
+ let _langchain_core_utils_env = require("@langchain/core/utils/env");
4
+ let _langchain_openai = require("@langchain/openai");
5
+ let _langchain_core_outputs = require("@langchain/core/outputs");
7
6
 
8
7
  //#region src/chat_models.ts
9
8
  /**
@@ -356,7 +355,7 @@ const __langchain_core_outputs = require_rolldown_runtime.__toESM(require("@lang
356
355
  *
357
356
  * <br />
358
357
  */
359
- var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
358
+ var ChatDeepSeek = class extends _langchain_openai.ChatOpenAICompletions {
360
359
  static lc_name() {
361
360
  return "ChatDeepSeek";
362
361
  }
@@ -373,7 +372,7 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
373
372
  "deepseek"
374
373
  ];
375
374
  constructor(fields) {
376
- const apiKey = fields?.apiKey || (0, __langchain_core_utils_env.getEnvironmentVariable)("DEEPSEEK_API_KEY");
375
+ const apiKey = fields?.apiKey || (0, _langchain_core_utils_env.getEnvironmentVariable)("DEEPSEEK_API_KEY");
377
376
  if (!apiKey) throw new Error(`Deepseek API key not found. Please set the DEEPSEEK_API_KEY environment variable or pass the key into "apiKey" field.`);
378
377
  super({
379
378
  ...fields,
@@ -413,31 +412,27 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
413
412
  isThinking = true;
414
413
  const thinkIndex = tokensBuffer.indexOf("<think>");
415
414
  const beforeThink = tokensBuffer.substring(0, thinkIndex);
416
- const afterThink = tokensBuffer.substring(thinkIndex + 7);
417
- tokensBuffer = afterThink || "";
418
- if (beforeThink) {
419
- const newChunk = new __langchain_core_outputs.ChatGenerationChunk({
420
- message: new __langchain_core_messages.AIMessageChunk({
421
- content: beforeThink,
422
- additional_kwargs: chunk.message.additional_kwargs,
423
- response_metadata: chunk.message.response_metadata,
424
- tool_calls: chunk.message.tool_calls,
425
- tool_call_chunks: chunk.message.tool_call_chunks,
426
- id: chunk.message.id
427
- }),
428
- text: beforeThink,
429
- generationInfo: chunk.generationInfo
430
- });
431
- yield newChunk;
432
- }
415
+ tokensBuffer = tokensBuffer.substring(thinkIndex + 7) || "";
416
+ if (beforeThink) yield new _langchain_core_outputs.ChatGenerationChunk({
417
+ message: new _langchain_core_messages.AIMessageChunk({
418
+ content: beforeThink,
419
+ additional_kwargs: chunk.message.additional_kwargs,
420
+ response_metadata: chunk.message.response_metadata,
421
+ tool_calls: chunk.message.tool_calls,
422
+ tool_call_chunks: chunk.message.tool_call_chunks,
423
+ id: chunk.message.id
424
+ }),
425
+ text: beforeThink,
426
+ generationInfo: chunk.generationInfo
427
+ });
433
428
  }
434
429
  if (isThinking && tokensBuffer.includes("</think>")) {
435
430
  isThinking = false;
436
431
  const thinkEndIndex = tokensBuffer.indexOf("</think>");
437
432
  const thoughtContent = tokensBuffer.substring(0, thinkEndIndex);
438
433
  const afterThink = tokensBuffer.substring(thinkEndIndex + 8);
439
- const reasoningChunk = new __langchain_core_outputs.ChatGenerationChunk({
440
- message: new __langchain_core_messages.AIMessageChunk({
434
+ yield new _langchain_core_outputs.ChatGenerationChunk({
435
+ message: new _langchain_core_messages.AIMessageChunk({
441
436
  content: "",
442
437
  additional_kwargs: {
443
438
  ...chunk.message.additional_kwargs,
@@ -451,11 +446,10 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
451
446
  text: "",
452
447
  generationInfo: chunk.generationInfo
453
448
  });
454
- yield reasoningChunk;
455
449
  tokensBuffer = afterThink || "";
456
450
  if (tokensBuffer) {
457
- const contentChunk = new __langchain_core_outputs.ChatGenerationChunk({
458
- message: new __langchain_core_messages.AIMessageChunk({
451
+ yield new _langchain_core_outputs.ChatGenerationChunk({
452
+ message: new _langchain_core_messages.AIMessageChunk({
459
453
  content: tokensBuffer,
460
454
  additional_kwargs: chunk.message.additional_kwargs,
461
455
  response_metadata: chunk.message.response_metadata,
@@ -466,7 +460,6 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
466
460
  text: tokensBuffer,
467
461
  generationInfo: chunk.generationInfo
468
462
  });
469
- yield contentChunk;
470
463
  tokensBuffer = "";
471
464
  }
472
465
  } else if (isThinking) {
@@ -478,28 +471,25 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
478
471
  }
479
472
  if (splitIndex !== -1) {
480
473
  const safeToYield = tokensBuffer.substring(0, splitIndex);
481
- if (safeToYield) {
482
- const reasoningChunk = new __langchain_core_outputs.ChatGenerationChunk({
483
- message: new __langchain_core_messages.AIMessageChunk({
484
- content: "",
485
- additional_kwargs: {
486
- ...chunk.message.additional_kwargs,
487
- reasoning_content: safeToYield
488
- },
489
- response_metadata: chunk.message.response_metadata,
490
- tool_calls: chunk.message.tool_calls,
491
- tool_call_chunks: chunk.message.tool_call_chunks,
492
- id: chunk.message.id
493
- }),
494
- text: "",
495
- generationInfo: chunk.generationInfo
496
- });
497
- yield reasoningChunk;
498
- }
474
+ if (safeToYield) yield new _langchain_core_outputs.ChatGenerationChunk({
475
+ message: new _langchain_core_messages.AIMessageChunk({
476
+ content: "",
477
+ additional_kwargs: {
478
+ ...chunk.message.additional_kwargs,
479
+ reasoning_content: safeToYield
480
+ },
481
+ response_metadata: chunk.message.response_metadata,
482
+ tool_calls: chunk.message.tool_calls,
483
+ tool_call_chunks: chunk.message.tool_call_chunks,
484
+ id: chunk.message.id
485
+ }),
486
+ text: "",
487
+ generationInfo: chunk.generationInfo
488
+ });
499
489
  tokensBuffer = tokensBuffer.substring(splitIndex);
500
490
  } else if (tokensBuffer) {
501
- const reasoningChunk = new __langchain_core_outputs.ChatGenerationChunk({
502
- message: new __langchain_core_messages.AIMessageChunk({
491
+ yield new _langchain_core_outputs.ChatGenerationChunk({
492
+ message: new _langchain_core_messages.AIMessageChunk({
503
493
  content: "",
504
494
  additional_kwargs: {
505
495
  ...chunk.message.additional_kwargs,
@@ -513,7 +503,6 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
513
503
  text: "",
514
504
  generationInfo: chunk.generationInfo
515
505
  });
516
- yield reasoningChunk;
517
506
  tokensBuffer = "";
518
507
  }
519
508
  } else {
@@ -525,25 +514,22 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
525
514
  }
526
515
  if (splitIndex !== -1) {
527
516
  const safeToYield = tokensBuffer.substring(0, splitIndex);
528
- if (safeToYield) {
529
- const contentChunk = new __langchain_core_outputs.ChatGenerationChunk({
530
- message: new __langchain_core_messages.AIMessageChunk({
531
- content: safeToYield,
532
- additional_kwargs: chunk.message.additional_kwargs,
533
- response_metadata: chunk.message.response_metadata,
534
- tool_calls: chunk.message.tool_calls,
535
- tool_call_chunks: chunk.message.tool_call_chunks,
536
- id: chunk.message.id
537
- }),
538
- text: safeToYield,
539
- generationInfo: chunk.generationInfo
540
- });
541
- yield contentChunk;
542
- }
517
+ if (safeToYield) yield new _langchain_core_outputs.ChatGenerationChunk({
518
+ message: new _langchain_core_messages.AIMessageChunk({
519
+ content: safeToYield,
520
+ additional_kwargs: chunk.message.additional_kwargs,
521
+ response_metadata: chunk.message.response_metadata,
522
+ tool_calls: chunk.message.tool_calls,
523
+ tool_call_chunks: chunk.message.tool_call_chunks,
524
+ id: chunk.message.id
525
+ }),
526
+ text: safeToYield,
527
+ generationInfo: chunk.generationInfo
528
+ });
543
529
  tokensBuffer = tokensBuffer.substring(splitIndex);
544
530
  } else if (tokensBuffer) {
545
- const contentChunk = new __langchain_core_outputs.ChatGenerationChunk({
546
- message: new __langchain_core_messages.AIMessageChunk({
531
+ yield new _langchain_core_outputs.ChatGenerationChunk({
532
+ message: new _langchain_core_messages.AIMessageChunk({
547
533
  content: tokensBuffer,
548
534
  additional_kwargs: chunk.message.additional_kwargs,
549
535
  response_metadata: chunk.message.response_metadata,
@@ -554,27 +540,21 @@ var ChatDeepSeek = class extends __langchain_openai.ChatOpenAICompletions {
554
540
  text: tokensBuffer,
555
541
  generationInfo: chunk.generationInfo
556
542
  });
557
- yield contentChunk;
558
543
  tokensBuffer = "";
559
544
  }
560
545
  }
561
546
  }
562
- if (tokensBuffer) if (isThinking) {
563
- const reasoningChunk = new __langchain_core_outputs.ChatGenerationChunk({
564
- message: new __langchain_core_messages.AIMessageChunk({
565
- content: "",
566
- additional_kwargs: { reasoning_content: tokensBuffer }
567
- }),
568
- text: ""
569
- });
570
- yield reasoningChunk;
571
- } else {
572
- const contentChunk = new __langchain_core_outputs.ChatGenerationChunk({
573
- message: new __langchain_core_messages.AIMessageChunk({ content: tokensBuffer }),
574
- text: tokensBuffer
575
- });
576
- yield contentChunk;
577
- }
547
+ if (tokensBuffer) if (isThinking) yield new _langchain_core_outputs.ChatGenerationChunk({
548
+ message: new _langchain_core_messages.AIMessageChunk({
549
+ content: "",
550
+ additional_kwargs: { reasoning_content: tokensBuffer }
551
+ }),
552
+ text: ""
553
+ });
554
+ else yield new _langchain_core_outputs.ChatGenerationChunk({
555
+ message: new _langchain_core_messages.AIMessageChunk({ content: tokensBuffer }),
556
+ text: tokensBuffer
557
+ });
578
558
  }
579
559
  _convertCompletionsMessageToBaseMessage(message, rawResponse) {
580
560
  const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.cjs","names":["ChatOpenAICompletions","fields?: Partial<ChatDeepSeekInput>","delta: Record<string, any>","rawResponse: OpenAIClient.ChatCompletionChunk","defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"","messages: BaseMessage[]","options: this[\"ParsedCallOptions\"]","runManager?: CallbackManagerForLLMRun","ChatGenerationChunk","AIMessageChunk","message: OpenAIClient.ChatCompletionMessage","rawResponse: OpenAIClient.ChatCompletion","PROFILES","outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>","config?: StructuredOutputMethodOptions<boolean>"],"sources":["../src/chat_models.ts"],"sourcesContent":["import {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseMessage, AIMessageChunk } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport {\n ChatOpenAICallOptions,\n ChatOpenAICompletions,\n ChatOpenAIFields,\n OpenAIClient,\n} from \"@langchain/openai\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport PROFILES from \"./profiles.js\";\n\nexport interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {\n headers?: Record<string, string>;\n}\n\nexport interface ChatDeepSeekInput extends ChatOpenAIFields {\n /**\n * The Deepseek API key to use for requests.\n * @default process.env.DEEPSEEK_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n}\n\n/**\n * Deepseek chat model integration.\n *\n * The Deepseek API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.\n *\n * ```bash\n * npm install @langchain/deepseek\n * export DEEPSEEK_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatDeepSeek } from '@langchain/deepseek';\n *\n * const llm = new ChatDeepSeek({\n * model: \"deepseek-reasoner\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatDeepSeek({\n * model: \"deepseek-chat\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatDeepSeek extends ChatOpenAICompletions<ChatDeepSeekCallOptions> {\n static lc_name() {\n return \"ChatDeepSeek\";\n }\n\n _llmType() {\n return \"deepseek\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n apiKey: \"DEEPSEEK_API_KEY\",\n };\n }\n\n lc_serializable = true;\n\n lc_namespace = [\"langchain\", \"chat_models\", \"deepseek\"];\n\n constructor(fields?: Partial<ChatDeepSeekInput>) {\n const apiKey = fields?.apiKey || getEnvironmentVariable(\"DEEPSEEK_API_KEY\");\n if (!apiKey) {\n throw new Error(\n `Deepseek API key not found. Please set the DEEPSEEK_API_KEY environment variable or pass the key into \"apiKey\" field.`\n );\n }\n\n super({\n ...fields,\n apiKey,\n configuration: {\n baseURL: \"https://api.deepseek.com\",\n ...fields?.configuration,\n },\n });\n }\n\n protected override _convertCompletionsDeltaToBaseMessageChunk(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delta: Record<string, any>,\n rawResponse: OpenAIClient.ChatCompletionChunk,\n defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"\n ) {\n const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(\n delta,\n rawResponse,\n defaultRole\n );\n messageChunk.additional_kwargs.reasoning_content = delta.reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n messageChunk.response_metadata = {\n ...messageChunk.response_metadata,\n model_provider: \"deepseek\",\n };\n return messageChunk;\n }\n\n async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this[\"ParsedCallOptions\"],\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const stream = super._streamResponseChunks(messages, options, runManager);\n\n // State for parsing <think> tags\n let tokensBuffer = \"\";\n let isThinking = false;\n\n for await (const chunk of stream) {\n if (options.signal?.aborted) {\n return;\n }\n // If the model already provided reasoning_content natively, just yield it\n if (chunk.message.additional_kwargs.reasoning_content) {\n yield chunk;\n continue;\n }\n\n const text = chunk.text;\n if (!text) {\n yield chunk;\n continue;\n }\n\n // Append text to buffer to handle split tags\n tokensBuffer += text;\n\n // Check for <think> start tag\n if (!isThinking && tokensBuffer.includes(\"<think>\")) {\n isThinking = true;\n const thinkIndex = tokensBuffer.indexOf(\"<think>\");\n const beforeThink = tokensBuffer.substring(0, thinkIndex);\n const afterThink = tokensBuffer.substring(\n thinkIndex + \"<think>\".length\n );\n\n // We consumed up to <think>, so buffer becomes what's after\n tokensBuffer = afterThink || \"\"; // might be empty or part of thought\n\n if (beforeThink) {\n // Send the content before the tag\n const newChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: beforeThink,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: beforeThink,\n generationInfo: chunk.generationInfo,\n });\n yield newChunk;\n }\n }\n\n // Check for </think> end tag\n if (isThinking && tokensBuffer.includes(\"</think>\")) {\n isThinking = false;\n const thinkEndIndex = tokensBuffer.indexOf(\"</think>\");\n const thoughtContent = tokensBuffer.substring(0, thinkEndIndex);\n const afterThink = tokensBuffer.substring(\n thinkEndIndex + \"</think>\".length\n );\n\n // Yield the reasoning content\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: thoughtContent,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n\n // Reset buffer to what's after </think>\n tokensBuffer = afterThink || \"\";\n\n // Yield the rest as normal content if any\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\"; // consumed\n }\n } else if (isThinking) {\n // We are inside thinking block.\n // Check partial </think> match\n const possibleEndTag = \"</think>\";\n let splitIndex = -1;\n\n // Check if buffer ends with a prefix of </think> - Greedy check (longest first)\n for (let i = possibleEndTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleEndTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: safeToYield,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // content is safe to yield as reasoning\n if (tokensBuffer) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: tokensBuffer,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n tokensBuffer = \"\";\n }\n }\n } else {\n // NOT thinking.\n // Check partial start tag \"<think>\" - Greedy check (longest first)\n const possibleStartTag = \"<think>\";\n let splitIndex = -1;\n for (let i = possibleStartTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleStartTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n // Yield safe content\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: safeToYield,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: safeToYield,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // Yield all\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\";\n }\n }\n }\n }\n\n // Flush remaining buffer at end of stream\n if (tokensBuffer) {\n // If we were thinking, it's unclosed thought.\n if (isThinking) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: { reasoning_content: tokensBuffer },\n }),\n text: \"\",\n });\n yield reasoningChunk;\n } else {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n }),\n text: tokensBuffer,\n });\n yield contentChunk;\n }\n }\n }\n\n protected override _convertCompletionsMessageToBaseMessage(\n message: OpenAIClient.ChatCompletionMessage,\n rawResponse: OpenAIClient.ChatCompletion\n ) {\n const langChainMessage = super._convertCompletionsMessageToBaseMessage(\n message,\n rawResponse\n );\n langChainMessage.additional_kwargs.reasoning_content =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (message as any).reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n langChainMessage.response_metadata = {\n ...langChainMessage.response_metadata,\n model_provider: \"deepseek\",\n };\n return langChainMessage;\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatDeepSeek({ model: \"deepseek-chat\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // false\n * ```\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n const ensuredConfig = { ...config };\n // Deepseek does not support json schema yet\n if (ensuredConfig?.method === undefined) {\n ensuredConfig.method = \"functionCalling\";\n }\n return super.withStructuredOutput<RunOutput>(outputSchema, ensuredConfig);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyZA,IAAa,eAAb,cAAkCA,yCAA+C;CAC/E,OAAO,UAAU;AACf,SAAO;CACR;CAED,WAAW;AACT,SAAO;CACR;CAED,IAAI,aAAoD;AACtD,SAAO,EACL,QAAQ,mBACT;CACF;CAED,kBAAkB;CAElB,eAAe;EAAC;EAAa;EAAe;CAAW;CAEvD,YAAYC,QAAqC;EAC/C,MAAM,SAAS,QAAQ,iEAAiC,mBAAmB;AAC3E,MAAI,CAAC,OACH,OAAM,IAAI,MACR,CAAC,qHAAqH,CAAC;EAI3H,MAAM;GACJ,GAAG;GACH;GACA,eAAe;IACb,SAAS;IACT,GAAG,QAAQ;GACZ;EACF,EAAC;CACH;CAED,AAAmB,2CAEjBC,OACAC,aACAC,aAOA;EACA,MAAM,eAAe,MAAM,2CACzB,OACA,aACA,YACD;EACD,aAAa,kBAAkB,oBAAoB,MAAM;EAEzD,aAAa,oBAAoB;GAC/B,GAAG,aAAa;GAChB,gBAAgB;EACjB;AACD,SAAO;CACR;CAED,OAAO,sBACLC,UACAC,SACAC,YACqC;EACrC,MAAM,SAAS,MAAM,sBAAsB,UAAU,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AmB,MAAM,wCAC7B,SACA,YACD;EACD,iBAAiB,kBAAkB,oBAEhC,QAAgB;EAEnB,iBAAiB,oBAAoB;GACnC,GAAG,iBAAiB;GACpB,gBAAgB;EACjB;AACD,SAAO;CACR;;;;;;;;;;;;;;;;;;CAmBD,IAAI,UAAwB;AAC1B,SAAOC,yBAAS,KAAK,UAAU,CAAE;CAClC;CAqCD,qBAIEC,cAIAC,QAMI;EACJ,MAAM,gBAAgB,EAAE,GAAG,OAAQ;AAEnC,MAAI,eAAe,WAAW,QAC5B,cAAc,SAAS;AAEzB,SAAO,MAAM,qBAAgC,cAAc,cAAc;CAC1E;AACF"}
1
+ {"version":3,"file":"chat_models.cjs","names":["ChatOpenAICompletions","ChatGenerationChunk","AIMessageChunk","PROFILES"],"sources":["../src/chat_models.ts"],"sourcesContent":["import {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseMessage, AIMessageChunk } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport {\n ChatOpenAICallOptions,\n ChatOpenAICompletions,\n ChatOpenAIFields,\n OpenAIClient,\n} from \"@langchain/openai\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport PROFILES from \"./profiles.js\";\n\nexport interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {\n headers?: Record<string, string>;\n}\n\nexport interface ChatDeepSeekInput extends ChatOpenAIFields {\n /**\n * The Deepseek API key to use for requests.\n * @default process.env.DEEPSEEK_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n}\n\n/**\n * Deepseek chat model integration.\n *\n * The Deepseek API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.\n *\n * ```bash\n * npm install @langchain/deepseek\n * export DEEPSEEK_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatDeepSeek } from '@langchain/deepseek';\n *\n * const llm = new ChatDeepSeek({\n * model: \"deepseek-reasoner\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatDeepSeek({\n * model: \"deepseek-chat\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatDeepSeek extends ChatOpenAICompletions<ChatDeepSeekCallOptions> {\n static lc_name() {\n return \"ChatDeepSeek\";\n }\n\n _llmType() {\n return \"deepseek\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n apiKey: \"DEEPSEEK_API_KEY\",\n };\n }\n\n lc_serializable = true;\n\n lc_namespace = [\"langchain\", \"chat_models\", \"deepseek\"];\n\n constructor(fields?: Partial<ChatDeepSeekInput>) {\n const apiKey = fields?.apiKey || getEnvironmentVariable(\"DEEPSEEK_API_KEY\");\n if (!apiKey) {\n throw new Error(\n `Deepseek API key not found. Please set the DEEPSEEK_API_KEY environment variable or pass the key into \"apiKey\" field.`\n );\n }\n\n super({\n ...fields,\n apiKey,\n configuration: {\n baseURL: \"https://api.deepseek.com\",\n ...fields?.configuration,\n },\n });\n }\n\n protected override _convertCompletionsDeltaToBaseMessageChunk(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delta: Record<string, any>,\n rawResponse: OpenAIClient.ChatCompletionChunk,\n defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"\n ) {\n const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(\n delta,\n rawResponse,\n defaultRole\n );\n messageChunk.additional_kwargs.reasoning_content = delta.reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n messageChunk.response_metadata = {\n ...messageChunk.response_metadata,\n model_provider: \"deepseek\",\n };\n return messageChunk;\n }\n\n async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this[\"ParsedCallOptions\"],\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const stream = super._streamResponseChunks(messages, options, runManager);\n\n // State for parsing <think> tags\n let tokensBuffer = \"\";\n let isThinking = false;\n\n for await (const chunk of stream) {\n if (options.signal?.aborted) {\n return;\n }\n // If the model already provided reasoning_content natively, just yield it\n if (chunk.message.additional_kwargs.reasoning_content) {\n yield chunk;\n continue;\n }\n\n const text = chunk.text;\n if (!text) {\n yield chunk;\n continue;\n }\n\n // Append text to buffer to handle split tags\n tokensBuffer += text;\n\n // Check for <think> start tag\n if (!isThinking && tokensBuffer.includes(\"<think>\")) {\n isThinking = true;\n const thinkIndex = tokensBuffer.indexOf(\"<think>\");\n const beforeThink = tokensBuffer.substring(0, thinkIndex);\n const afterThink = tokensBuffer.substring(\n thinkIndex + \"<think>\".length\n );\n\n // We consumed up to <think>, so buffer becomes what's after\n tokensBuffer = afterThink || \"\"; // might be empty or part of thought\n\n if (beforeThink) {\n // Send the content before the tag\n const newChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: beforeThink,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: beforeThink,\n generationInfo: chunk.generationInfo,\n });\n yield newChunk;\n }\n }\n\n // Check for </think> end tag\n if (isThinking && tokensBuffer.includes(\"</think>\")) {\n isThinking = false;\n const thinkEndIndex = tokensBuffer.indexOf(\"</think>\");\n const thoughtContent = tokensBuffer.substring(0, thinkEndIndex);\n const afterThink = tokensBuffer.substring(\n thinkEndIndex + \"</think>\".length\n );\n\n // Yield the reasoning content\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: thoughtContent,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n\n // Reset buffer to what's after </think>\n tokensBuffer = afterThink || \"\";\n\n // Yield the rest as normal content if any\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\"; // consumed\n }\n } else if (isThinking) {\n // We are inside thinking block.\n // Check partial </think> match\n const possibleEndTag = \"</think>\";\n let splitIndex = -1;\n\n // Check if buffer ends with a prefix of </think> - Greedy check (longest first)\n for (let i = possibleEndTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleEndTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: safeToYield,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // content is safe to yield as reasoning\n if (tokensBuffer) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: tokensBuffer,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n tokensBuffer = \"\";\n }\n }\n } else {\n // NOT thinking.\n // Check partial start tag \"<think>\" - Greedy check (longest first)\n const possibleStartTag = \"<think>\";\n let splitIndex = -1;\n for (let i = possibleStartTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleStartTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n // Yield safe content\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: safeToYield,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: safeToYield,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // Yield all\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\";\n }\n }\n }\n }\n\n // Flush remaining buffer at end of stream\n if (tokensBuffer) {\n // If we were thinking, it's unclosed thought.\n if (isThinking) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: { reasoning_content: tokensBuffer },\n }),\n text: \"\",\n });\n yield reasoningChunk;\n } else {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n }),\n text: tokensBuffer,\n });\n yield contentChunk;\n }\n }\n }\n\n protected override _convertCompletionsMessageToBaseMessage(\n message: OpenAIClient.ChatCompletionMessage,\n rawResponse: OpenAIClient.ChatCompletion\n ) {\n const langChainMessage = super._convertCompletionsMessageToBaseMessage(\n message,\n rawResponse\n );\n langChainMessage.additional_kwargs.reasoning_content =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (message as any).reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n langChainMessage.response_metadata = {\n ...langChainMessage.response_metadata,\n model_provider: \"deepseek\",\n };\n return langChainMessage;\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatDeepSeek({ model: \"deepseek-chat\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // false\n * ```\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n const ensuredConfig = { ...config };\n // Deepseek does not support json schema yet\n if (ensuredConfig?.method === undefined) {\n ensuredConfig.method = \"functionCalling\";\n }\n return super.withStructuredOutput<RunOutput>(outputSchema, ensuredConfig);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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U,WAAW;eAG7C,cAAc;AAahB,WAZqB,IAAID,4CAAoB;MAC3C,SAAS,IAAIC,wCAAe;OAC1B,SAAS;OACT,mBAAmB,MAAM,QAAQ;OACjC,mBAAmB,MAAM,QAAQ;OACjC,YAAY,MAAM,QAAQ;OAC1B,kBAAkB,MAAM,QAAQ;OAChC,IAAI,MAAM,QAAQ;OACnB,CAAC;MACF,MAAM;MACN,gBAAgB,MAAM;MACvB,CAAC;AAEF,oBAAe;;;;AAOvB,MAAI,aAEF,KAAI,WAQF,OAPuB,IAAID,4CAAoB;GAC7C,SAAS,IAAIC,wCAAe;IAC1B,SAAS;IACT,mBAAmB,EAAE,mBAAmB,cAAc;IACvD,CAAC;GACF,MAAM;GACP,CAAC;MASF,OANqB,IAAID,4CAAoB;GAC3C,SAAS,IAAIC,wCAAe,EAC1B,SAAS,cACV,CAAC;GACF,MAAM;GACP,CAAC;;CAMR,AAAmB,wCACjB,SACA,aACA;EACA,MAAM,mBAAmB,MAAM,wCAC7B,SACA,YACD;AACD,mBAAiB,kBAAkB,oBAEhC,QAAgB;AAEnB,mBAAiB,oBAAoB;GACnC,GAAG,iBAAiB;GACpB,gBAAgB;GACjB;AACD,SAAO;;;;;;;;;;;;;;;;;;;CAoBT,IAAI,UAAwB;AAC1B,SAAOC,yBAAS,KAAK,UAAU,EAAE;;CAsCnC,qBAIE,cAIA,QAMI;EACJ,MAAM,gBAAgB,EAAE,GAAG,QAAQ;AAEnC,MAAI,eAAe,WAAW,OAC5B,eAAc,SAAS;AAEzB,SAAO,MAAM,qBAAgC,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.d.cts","names":["BaseLanguageModelInput","StructuredOutputMethodOptions","ModelProfile","BaseMessage","Runnable","InteropZodType","ChatOpenAICallOptions","ChatOpenAICompletions","ChatOpenAIFields","OpenAIClient","ChatGenerationChunk","CallbackManagerForLLMRun","ChatDeepSeekCallOptions","Record","ChatDeepSeekInput","Array","ChatDeepSeek","RunOutput","Partial","ChatCompletionChunk","_langchain_core_messages0","MessageToolSet","MessageStructure","MessageType","BaseMessageChunk","AsyncGenerator","ChatCompletionMessage","ChatCompletion"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { BaseLanguageModelInput, StructuredOutputMethodOptions } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { ChatOpenAICallOptions, ChatOpenAICompletions, ChatOpenAIFields, OpenAIClient } from \"@langchain/openai\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nexport interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {\n headers?: Record<string, string>;\n}\nexport interface ChatDeepSeekInput extends ChatOpenAIFields {\n /**\n * The Deepseek API key to use for requests.\n * @default process.env.DEEPSEEK_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n}\n/**\n * Deepseek chat model integration.\n *\n * The Deepseek API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.\n *\n * ```bash\n * npm install @langchain/deepseek\n * export DEEPSEEK_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatDeepSeek } from '@langchain/deepseek';\n *\n * const llm = new ChatDeepSeek({\n * model: \"deepseek-reasoner\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatDeepSeek({\n * model: \"deepseek-chat\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatDeepSeek extends ChatOpenAICompletions<ChatDeepSeekCallOptions> {\n static lc_name(): string;\n _llmType(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n lc_serializable: boolean;\n lc_namespace: string[];\n constructor(fields?: Partial<ChatDeepSeekInput>);\n protected _convertCompletionsDeltaToBaseMessageChunk(delta: Record<string, any>, rawResponse: OpenAIClient.ChatCompletionChunk, defaultRole?: \"function\" | \"user\" | \"system\" | \"developer\" | \"assistant\" | \"tool\"): import(\"@langchain/core/messages\").BaseMessageChunk<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>;\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n protected _convertCompletionsMessageToBaseMessage(message: OpenAIClient.ChatCompletionMessage, rawResponse: OpenAIClient.ChatCompletion): BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatDeepSeek({ model: \"deepseek-chat\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // false\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\n//# sourceMappingURL=chat_models.d.ts.map"],"mappings":";;;;;;;;;;;UAQiBY,uBAAAA,SAAgCN;YACnCO;;AADGD,UAGAE,iBAAAA,SAA0BN,gBAHMF,CAAAA;EAGhCQ;;;;EAA0C,MAAA,CAAA,EAAA,MAAA;EAiYtCE;;;EAQIE,KAAAA,CAAAA,EAAAA,MAAAA;EACuCL;;;;;EAAkWO,IAAAA,CAAAA,EA3XvZL,KA2XuZK,CAAAA,MAAAA,CAAAA;EAC9XjB;;;;EAC2BM,aAAaiB,CAAAA,EAxXxDX,KAwXwDW,CAAAA,MAAAA,CAAAA;EAAoCjB;;;EAA6FW,SAAAA,CAAAA,EAAAA,OAAAA;EAA/DjB;;;EAmB7EU,WAAAA,CAAAA,EAAAA,MAAAA;EAAkDI;;;;EAA2FjB,SAAAA,CAAAA,EAAAA,MAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA9B/I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA1CgB,Y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SAAA,IAEf,MAAA,eACJ,MAAA,GAAS,6BAAA,SACR,QAAA,CAAS,sBAAA;IAA0B,GAAA,EAAK,WAAA;IAAa,MAAA,EAAQ,SAAA;EAAA;EAEhE,oBAAA,mBAEoB,MAAA,gBAAsB,MAAA,cAAA,CAExC,YAAA,EACI,cAAA,CAAe,SAAA,IAEf,MAAA,eACJ,MAAA,GAAS,6BAAA,YAEP,QAAA,CAAS,sBAAA,EAAwB,SAAA,IACjC,QAAA,CAAS,sBAAA;IAA0B,GAAA,EAAK,WAAA;IAAa,MAAA,EAAQ,SAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.d.ts","names":["BaseLanguageModelInput","StructuredOutputMethodOptions","ModelProfile","BaseMessage","Runnable","InteropZodType","ChatOpenAICallOptions","ChatOpenAICompletions","ChatOpenAIFields","OpenAIClient","ChatGenerationChunk","CallbackManagerForLLMRun","ChatDeepSeekCallOptions","Record","ChatDeepSeekInput","Array","ChatDeepSeek","RunOutput","Partial","ChatCompletionChunk","_langchain_core_messages0","MessageToolSet","MessageStructure","MessageType","BaseMessageChunk","AsyncGenerator","ChatCompletionMessage","ChatCompletion"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { BaseLanguageModelInput, StructuredOutputMethodOptions } from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { ChatOpenAICallOptions, ChatOpenAICompletions, ChatOpenAIFields, OpenAIClient } from \"@langchain/openai\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nexport interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {\n headers?: Record<string, string>;\n}\nexport interface ChatDeepSeekInput extends ChatOpenAIFields {\n /**\n * The Deepseek API key to use for requests.\n * @default process.env.DEEPSEEK_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n}\n/**\n * Deepseek chat model integration.\n *\n * The Deepseek API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.\n *\n * ```bash\n * npm install @langchain/deepseek\n * export DEEPSEEK_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatDeepSeek } from '@langchain/deepseek';\n *\n * const llm = new ChatDeepSeek({\n * model: \"deepseek-reasoner\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatDeepSeek({\n * model: \"deepseek-chat\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatDeepSeek extends ChatOpenAICompletions<ChatDeepSeekCallOptions> {\n static lc_name(): string;\n _llmType(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n lc_serializable: boolean;\n lc_namespace: string[];\n constructor(fields?: Partial<ChatDeepSeekInput>);\n protected _convertCompletionsDeltaToBaseMessageChunk(delta: Record<string, any>, rawResponse: OpenAIClient.ChatCompletionChunk, defaultRole?: \"function\" | \"user\" | \"system\" | \"developer\" | \"assistant\" | \"tool\"): import(\"@langchain/core/messages\").BaseMessageChunk<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>;\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n protected _convertCompletionsMessageToBaseMessage(message: OpenAIClient.ChatCompletionMessage, rawResponse: OpenAIClient.ChatCompletion): BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatDeepSeek({ model: \"deepseek-chat\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // false\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\n//# sourceMappingURL=chat_models.d.ts.map"],"mappings":";;;;;;;;;;;UAQiBY,uBAAAA,SAAgCN;YACnCO;;AADGD,UAGAE,iBAAAA,SAA0BN,gBAHMF,CAAAA;EAGhCQ;;;;EAA0C,MAAA,CAAA,EAAA,MAAA;EAiYtCE;;;EAQIE,KAAAA,CAAAA,EAAAA,MAAAA;EACuCL;;;;;EAAkWO,IAAAA,CAAAA,EA3XvZL,KA2XuZK,CAAAA,MAAAA,CAAAA;EAC9XjB;;;;EAC2BM,aAAaiB,CAAAA,EAxX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AA,CAPmC,yBAAA,CAOnC,cAAA,GAAA,yBAAA,CAAA,WAAA;EAgBL,qBAAA,CACL,QAAA,EAAU,WAAA,IACV,OAAA,6BACA,UAAA,GAAa,wBAAA,GACZ,cAAA,CAAe,mBAAA;EAAA,UA6OC,uCAAA,CACjB,OAAA,EAAS,YAAA,CAAa,qBAAA,EACtB,WAAA,EAAa,YAAA,CAAa,cAAA,GAAc,WAAA,CAAA,yBAAA,CAAA,gBAAA,CAAA,yBAAA,CAAA,cAAA,GAAA,yBAAA,CAAA,WAAA;;;;;;;;;;;;;;;;;;MAkCtC,OAAA,CAAA,GAAW,YAAA;EAIf,oBAAA,mBAEoB,MAAA,gBAAsB,MAAA,cAAA,CAExC,YAAA,EACI,cAAA,CAAe,SAAA,IAEf,MAAA,eACJ,MAAA,GAAS,6BAAA,UACR,QAAA,CAAS,sBAAA,EAAwB,SAAA;EAEpC,oBAAA,mBAEoB,MAAA,gBAAsB,MAAA,cAAA,CAExC,YAAA,EACI,cAAA,CAAe,SAAA,IAEf,MAAA,eACJ,MAAA,GAAS,6BAAA,SACR,QAAA,CAAS,sBAAA;IAA0B,GAAA,EAAK,WAAA;IAAa,MAAA,EAAQ,SAAA;EAAA;EAEhE,oBAAA,mBAEoB,MAAA,gBAAsB,MAAA,cAAA,CAExC,YAAA,EACI,cAAA,CAAe,SAAA,IAEf,MAAA,eACJ,MAAA,GAAS,6BAAA,YAEP,QAAA,CAAS,sBAAA,EAAwB,SAAA,IACjC,QAAA,CAAS,sBAAA;IAA0B,GAAA,EAAK,WAAA;IAAa,MAAA,EAAQ,SAAA;EAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import profiles_default from "./profiles.js";
1
+ import PROFILES from "./profiles.js";
2
2
  import { AIMessageChunk } from "@langchain/core/messages";
3
3
  import { getEnvironmentVariable } from "@langchain/core/utils/env";
4
4
  import { ChatOpenAICompletions } from "@langchain/openai";
@@ -412,30 +412,26 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
412
412
  isThinking = true;
413
413
  const thinkIndex = tokensBuffer.indexOf("<think>");
414
414
  const beforeThink = tokensBuffer.substring(0, thinkIndex);
415
- const afterThink = tokensBuffer.substring(thinkIndex + 7);
416
- tokensBuffer = afterThink || "";
417
- if (beforeThink) {
418
- const newChunk = new ChatGenerationChunk({
419
- message: new AIMessageChunk({
420
- content: beforeThink,
421
- additional_kwargs: chunk.message.additional_kwargs,
422
- response_metadata: chunk.message.response_metadata,
423
- tool_calls: chunk.message.tool_calls,
424
- tool_call_chunks: chunk.message.tool_call_chunks,
425
- id: chunk.message.id
426
- }),
427
- text: beforeThink,
428
- generationInfo: chunk.generationInfo
429
- });
430
- yield newChunk;
431
- }
415
+ tokensBuffer = tokensBuffer.substring(thinkIndex + 7) || "";
416
+ if (beforeThink) yield new ChatGenerationChunk({
417
+ message: new AIMessageChunk({
418
+ content: beforeThink,
419
+ additional_kwargs: chunk.message.additional_kwargs,
420
+ response_metadata: chunk.message.response_metadata,
421
+ tool_calls: chunk.message.tool_calls,
422
+ tool_call_chunks: chunk.message.tool_call_chunks,
423
+ id: chunk.message.id
424
+ }),
425
+ text: beforeThink,
426
+ generationInfo: chunk.generationInfo
427
+ });
432
428
  }
433
429
  if (isThinking && tokensBuffer.includes("</think>")) {
434
430
  isThinking = false;
435
431
  const thinkEndIndex = tokensBuffer.indexOf("</think>");
436
432
  const thoughtContent = tokensBuffer.substring(0, thinkEndIndex);
437
433
  const afterThink = tokensBuffer.substring(thinkEndIndex + 8);
438
- const reasoningChunk = new ChatGenerationChunk({
434
+ yield new ChatGenerationChunk({
439
435
  message: new AIMessageChunk({
440
436
  content: "",
441
437
  additional_kwargs: {
@@ -450,10 +446,9 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
450
446
  text: "",
451
447
  generationInfo: chunk.generationInfo
452
448
  });
453
- yield reasoningChunk;
454
449
  tokensBuffer = afterThink || "";
455
450
  if (tokensBuffer) {
456
- const contentChunk = new ChatGenerationChunk({
451
+ yield new ChatGenerationChunk({
457
452
  message: new AIMessageChunk({
458
453
  content: tokensBuffer,
459
454
  additional_kwargs: chunk.message.additional_kwargs,
@@ -465,7 +460,6 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
465
460
  text: tokensBuffer,
466
461
  generationInfo: chunk.generationInfo
467
462
  });
468
- yield contentChunk;
469
463
  tokensBuffer = "";
470
464
  }
471
465
  } else if (isThinking) {
@@ -477,27 +471,24 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
477
471
  }
478
472
  if (splitIndex !== -1) {
479
473
  const safeToYield = tokensBuffer.substring(0, splitIndex);
480
- if (safeToYield) {
481
- const reasoningChunk = new ChatGenerationChunk({
482
- message: new AIMessageChunk({
483
- content: "",
484
- additional_kwargs: {
485
- ...chunk.message.additional_kwargs,
486
- reasoning_content: safeToYield
487
- },
488
- response_metadata: chunk.message.response_metadata,
489
- tool_calls: chunk.message.tool_calls,
490
- tool_call_chunks: chunk.message.tool_call_chunks,
491
- id: chunk.message.id
492
- }),
493
- text: "",
494
- generationInfo: chunk.generationInfo
495
- });
496
- yield reasoningChunk;
497
- }
474
+ if (safeToYield) yield new ChatGenerationChunk({
475
+ message: new AIMessageChunk({
476
+ content: "",
477
+ additional_kwargs: {
478
+ ...chunk.message.additional_kwargs,
479
+ reasoning_content: safeToYield
480
+ },
481
+ response_metadata: chunk.message.response_metadata,
482
+ tool_calls: chunk.message.tool_calls,
483
+ tool_call_chunks: chunk.message.tool_call_chunks,
484
+ id: chunk.message.id
485
+ }),
486
+ text: "",
487
+ generationInfo: chunk.generationInfo
488
+ });
498
489
  tokensBuffer = tokensBuffer.substring(splitIndex);
499
490
  } else if (tokensBuffer) {
500
- const reasoningChunk = new ChatGenerationChunk({
491
+ yield new ChatGenerationChunk({
501
492
  message: new AIMessageChunk({
502
493
  content: "",
503
494
  additional_kwargs: {
@@ -512,7 +503,6 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
512
503
  text: "",
513
504
  generationInfo: chunk.generationInfo
514
505
  });
515
- yield reasoningChunk;
516
506
  tokensBuffer = "";
517
507
  }
518
508
  } else {
@@ -524,24 +514,21 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
524
514
  }
525
515
  if (splitIndex !== -1) {
526
516
  const safeToYield = tokensBuffer.substring(0, splitIndex);
527
- if (safeToYield) {
528
- const contentChunk = new ChatGenerationChunk({
529
- message: new AIMessageChunk({
530
- content: safeToYield,
531
- additional_kwargs: chunk.message.additional_kwargs,
532
- response_metadata: chunk.message.response_metadata,
533
- tool_calls: chunk.message.tool_calls,
534
- tool_call_chunks: chunk.message.tool_call_chunks,
535
- id: chunk.message.id
536
- }),
537
- text: safeToYield,
538
- generationInfo: chunk.generationInfo
539
- });
540
- yield contentChunk;
541
- }
517
+ if (safeToYield) yield new ChatGenerationChunk({
518
+ message: new AIMessageChunk({
519
+ content: safeToYield,
520
+ additional_kwargs: chunk.message.additional_kwargs,
521
+ response_metadata: chunk.message.response_metadata,
522
+ tool_calls: chunk.message.tool_calls,
523
+ tool_call_chunks: chunk.message.tool_call_chunks,
524
+ id: chunk.message.id
525
+ }),
526
+ text: safeToYield,
527
+ generationInfo: chunk.generationInfo
528
+ });
542
529
  tokensBuffer = tokensBuffer.substring(splitIndex);
543
530
  } else if (tokensBuffer) {
544
- const contentChunk = new ChatGenerationChunk({
531
+ yield new ChatGenerationChunk({
545
532
  message: new AIMessageChunk({
546
533
  content: tokensBuffer,
547
534
  additional_kwargs: chunk.message.additional_kwargs,
@@ -553,27 +540,21 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
553
540
  text: tokensBuffer,
554
541
  generationInfo: chunk.generationInfo
555
542
  });
556
- yield contentChunk;
557
543
  tokensBuffer = "";
558
544
  }
559
545
  }
560
546
  }
561
- if (tokensBuffer) if (isThinking) {
562
- const reasoningChunk = new ChatGenerationChunk({
563
- message: new AIMessageChunk({
564
- content: "",
565
- additional_kwargs: { reasoning_content: tokensBuffer }
566
- }),
567
- text: ""
568
- });
569
- yield reasoningChunk;
570
- } else {
571
- const contentChunk = new ChatGenerationChunk({
572
- message: new AIMessageChunk({ content: tokensBuffer }),
573
- text: tokensBuffer
574
- });
575
- yield contentChunk;
576
- }
547
+ if (tokensBuffer) if (isThinking) yield new ChatGenerationChunk({
548
+ message: new AIMessageChunk({
549
+ content: "",
550
+ additional_kwargs: { reasoning_content: tokensBuffer }
551
+ }),
552
+ text: ""
553
+ });
554
+ else yield new ChatGenerationChunk({
555
+ message: new AIMessageChunk({ content: tokensBuffer }),
556
+ text: tokensBuffer
557
+ });
577
558
  }
578
559
  _convertCompletionsMessageToBaseMessage(message, rawResponse) {
579
560
  const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
@@ -602,7 +583,7 @@ var ChatDeepSeek = class extends ChatOpenAICompletions {
602
583
  * ```
603
584
  */
604
585
  get profile() {
605
- return profiles_default[this.model] ?? {};
586
+ return PROFILES[this.model] ?? {};
606
587
  }
607
588
  withStructuredOutput(outputSchema, config) {
608
589
  const ensuredConfig = { ...config };
@@ -1 +1 @@
1
- {"version":3,"file":"chat_models.js","names":["fields?: Partial<ChatDeepSeekInput>","delta: Record<string, any>","rawResponse: OpenAIClient.ChatCompletionChunk","defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"","messages: BaseMessage[]","options: this[\"ParsedCallOptions\"]","runManager?: CallbackManagerForLLMRun","message: OpenAIClient.ChatCompletionMessage","rawResponse: OpenAIClient.ChatCompletion","PROFILES","outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>","config?: StructuredOutputMethodOptions<boolean>"],"sources":["../src/chat_models.ts"],"sourcesContent":["import {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseMessage, AIMessageChunk } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport {\n ChatOpenAICallOptions,\n ChatOpenAICompletions,\n ChatOpenAIFields,\n OpenAIClient,\n} from \"@langchain/openai\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport PROFILES from \"./profiles.js\";\n\nexport interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {\n headers?: Record<string, string>;\n}\n\nexport interface ChatDeepSeekInput extends ChatOpenAIFields {\n /**\n * The Deepseek API key to use for requests.\n * @default process.env.DEEPSEEK_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n}\n\n/**\n * Deepseek chat model integration.\n *\n * The Deepseek API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.\n *\n * ```bash\n * npm install @langchain/deepseek\n * export DEEPSEEK_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatDeepSeek } from '@langchain/deepseek';\n *\n * const llm = new ChatDeepSeek({\n * model: \"deepseek-reasoner\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatDeepSeek({\n * model: \"deepseek-chat\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatDeepSeek extends ChatOpenAICompletions<ChatDeepSeekCallOptions> {\n static lc_name() {\n return \"ChatDeepSeek\";\n }\n\n _llmType() {\n return \"deepseek\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n apiKey: \"DEEPSEEK_API_KEY\",\n };\n }\n\n lc_serializable = true;\n\n lc_namespace = [\"langchain\", \"chat_models\", \"deepseek\"];\n\n constructor(fields?: Partial<ChatDeepSeekInput>) {\n const apiKey = fields?.apiKey || getEnvironmentVariable(\"DEEPSEEK_API_KEY\");\n if (!apiKey) {\n throw new Error(\n `Deepseek API key not found. Please set the DEEPSEEK_API_KEY environment variable or pass the key into \"apiKey\" field.`\n );\n }\n\n super({\n ...fields,\n apiKey,\n configuration: {\n baseURL: \"https://api.deepseek.com\",\n ...fields?.configuration,\n },\n });\n }\n\n protected override _convertCompletionsDeltaToBaseMessageChunk(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delta: Record<string, any>,\n rawResponse: OpenAIClient.ChatCompletionChunk,\n defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"\n ) {\n const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(\n delta,\n rawResponse,\n defaultRole\n );\n messageChunk.additional_kwargs.reasoning_content = delta.reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n messageChunk.response_metadata = {\n ...messageChunk.response_metadata,\n model_provider: \"deepseek\",\n };\n return messageChunk;\n }\n\n async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this[\"ParsedCallOptions\"],\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const stream = super._streamResponseChunks(messages, options, runManager);\n\n // State for parsing <think> tags\n let tokensBuffer = \"\";\n let isThinking = false;\n\n for await (const chunk of stream) {\n if (options.signal?.aborted) {\n return;\n }\n // If the model already provided reasoning_content natively, just yield it\n if (chunk.message.additional_kwargs.reasoning_content) {\n yield chunk;\n continue;\n }\n\n const text = chunk.text;\n if (!text) {\n yield chunk;\n continue;\n }\n\n // Append text to buffer to handle split tags\n tokensBuffer += text;\n\n // Check for <think> start tag\n if (!isThinking && tokensBuffer.includes(\"<think>\")) {\n isThinking = true;\n const thinkIndex = tokensBuffer.indexOf(\"<think>\");\n const beforeThink = tokensBuffer.substring(0, thinkIndex);\n const afterThink = tokensBuffer.substring(\n thinkIndex + \"<think>\".length\n );\n\n // We consumed up to <think>, so buffer becomes what's after\n tokensBuffer = afterThink || \"\"; // might be empty or part of thought\n\n if (beforeThink) {\n // Send the content before the tag\n const newChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: beforeThink,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: beforeThink,\n generationInfo: chunk.generationInfo,\n });\n yield newChunk;\n }\n }\n\n // Check for </think> end tag\n if (isThinking && tokensBuffer.includes(\"</think>\")) {\n isThinking = false;\n const thinkEndIndex = tokensBuffer.indexOf(\"</think>\");\n const thoughtContent = tokensBuffer.substring(0, thinkEndIndex);\n const afterThink = tokensBuffer.substring(\n thinkEndIndex + \"</think>\".length\n );\n\n // Yield the reasoning content\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: thoughtContent,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n\n // Reset buffer to what's after </think>\n tokensBuffer = afterThink || \"\";\n\n // Yield the rest as normal content if any\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\"; // consumed\n }\n } else if (isThinking) {\n // We are inside thinking block.\n // Check partial </think> match\n const possibleEndTag = \"</think>\";\n let splitIndex = -1;\n\n // Check if buffer ends with a prefix of </think> - Greedy check (longest first)\n for (let i = possibleEndTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleEndTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: safeToYield,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // content is safe to yield as reasoning\n if (tokensBuffer) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: tokensBuffer,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n tokensBuffer = \"\";\n }\n }\n } else {\n // NOT thinking.\n // Check partial start tag \"<think>\" - Greedy check (longest first)\n const possibleStartTag = \"<think>\";\n let splitIndex = -1;\n for (let i = possibleStartTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleStartTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n // Yield safe content\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: safeToYield,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: safeToYield,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // Yield all\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\";\n }\n }\n }\n }\n\n // Flush remaining buffer at end of stream\n if (tokensBuffer) {\n // If we were thinking, it's unclosed thought.\n if (isThinking) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: { reasoning_content: tokensBuffer },\n }),\n text: \"\",\n });\n yield reasoningChunk;\n } else {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n }),\n text: tokensBuffer,\n });\n yield contentChunk;\n }\n }\n }\n\n protected override _convertCompletionsMessageToBaseMessage(\n message: OpenAIClient.ChatCompletionMessage,\n rawResponse: OpenAIClient.ChatCompletion\n ) {\n const langChainMessage = super._convertCompletionsMessageToBaseMessage(\n message,\n rawResponse\n );\n langChainMessage.additional_kwargs.reasoning_content =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (message as any).reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n langChainMessage.response_metadata = {\n ...langChainMessage.response_metadata,\n model_provider: \"deepseek\",\n };\n return langChainMessage;\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatDeepSeek({ model: \"deepseek-chat\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // false\n * ```\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n const ensuredConfig = { ...config };\n // Deepseek does not support json schema yet\n if (ensuredConfig?.method === undefined) {\n ensuredConfig.method = \"functionCalling\";\n }\n return super.withStructuredOutput<RunOutput>(outputSchema, ensuredConfig);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyZA,IAAa,eAAb,cAAkC,sBAA+C;CAC/E,OAAO,UAAU;AACf,SAAO;CACR;CAED,WAAW;AACT,SAAO;CACR;CAED,IAAI,aAAoD;AACtD,SAAO,EACL,QAAQ,mBACT;CACF;CAED,kBAAkB;CAElB,eAAe;EAAC;EAAa;EAAe;CAAW;CAEvD,YAAYA,QAAqC;EAC/C,MAAM,SAAS,QAAQ,UAAU,uBAAuB,mBAAmB;AAC3E,MAAI,CAAC,OACH,OAAM,IAAI,MACR,CAAC,qHAAqH,CAAC;EAI3H,MAAM;GACJ,GAAG;GACH;GACA,eAAe;IACb,SAAS;IACT,GAAG,QAAQ;GACZ;EACF,EAAC;CACH;CAED,AAAmB,2CAEjBC,OACAC,aACAC,aAOA;EACA,MAAM,eAAe,MAAM,2CACzB,OACA,aACA,YACD;EACD,aAAa,kBAAkB,oBAAoB,MAAM;EAEzD,aAAa,oBAAoB;GAC/B,GAAG,aAAa;GACh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IACD,MAAM;GACP;GACD,MAAM;EACP;CAEJ;CAED,AAAmB,wCACjBC,SACAC,aACA;EACA,MAAM,mBAAmB,MAAM,wCAC7B,SACA,YACD;EACD,iBAAiB,kBAAkB,oBAEhC,QAAgB;EAEnB,iBAAiB,oBAAoB;GACnC,GAAG,iBAAiB;GACpB,gBAAgB;EACjB;AACD,SAAO;CACR;;;;;;;;;;;;;;;;;;CAmBD,IAAI,UAAwB;AAC1B,SAAOC,iBAAS,KAAK,UAAU,CAAE;CAClC;CAqCD,qBAIEC,cAIAC,QAMI;EACJ,MAAM,gBAAgB,EAAE,GAAG,OAAQ;AAEnC,MAAI,eAAe,WAAW,QAC5B,cAAc,SAAS;AAEzB,SAAO,MAAM,qBAAgC,cAAc,cAAc;CAC1E;AACF"}
1
+ {"version":3,"file":"chat_models.js","names":[],"sources":["../src/chat_models.ts"],"sourcesContent":["import {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseMessage, AIMessageChunk } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport {\n ChatOpenAICallOptions,\n ChatOpenAICompletions,\n ChatOpenAIFields,\n OpenAIClient,\n} from \"@langchain/openai\";\nimport { ChatGenerationChunk } from \"@langchain/core/outputs\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport PROFILES from \"./profiles.js\";\n\nexport interface ChatDeepSeekCallOptions extends ChatOpenAICallOptions {\n headers?: Record<string, string>;\n}\n\nexport interface ChatDeepSeekInput extends ChatOpenAIFields {\n /**\n * The Deepseek API key to use for requests.\n * @default process.env.DEEPSEEK_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n}\n\n/**\n * Deepseek chat model integration.\n *\n * The Deepseek API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/deepseek` and set an environment variable named `DEEPSEEK_API_KEY`.\n *\n * ```bash\n * npm install @langchain/deepseek\n * export DEEPSEEK_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_deepseek.ChatDeepSeek.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_deepseek.ChatDeepSeekCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatDeepSeek } from '@langchain/deepseek';\n *\n * const llm = new ChatDeepSeek({\n * model: \"deepseek-reasoner\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {\n * \"reasoning_content\": \"...\",\n * },\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatDeepSeek({\n * model: \"deepseek-chat\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatDeepSeek extends ChatOpenAICompletions<ChatDeepSeekCallOptions> {\n static lc_name() {\n return \"ChatDeepSeek\";\n }\n\n _llmType() {\n return \"deepseek\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n apiKey: \"DEEPSEEK_API_KEY\",\n };\n }\n\n lc_serializable = true;\n\n lc_namespace = [\"langchain\", \"chat_models\", \"deepseek\"];\n\n constructor(fields?: Partial<ChatDeepSeekInput>) {\n const apiKey = fields?.apiKey || getEnvironmentVariable(\"DEEPSEEK_API_KEY\");\n if (!apiKey) {\n throw new Error(\n `Deepseek API key not found. Please set the DEEPSEEK_API_KEY environment variable or pass the key into \"apiKey\" field.`\n );\n }\n\n super({\n ...fields,\n apiKey,\n configuration: {\n baseURL: \"https://api.deepseek.com\",\n ...fields?.configuration,\n },\n });\n }\n\n protected override _convertCompletionsDeltaToBaseMessageChunk(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delta: Record<string, any>,\n rawResponse: OpenAIClient.ChatCompletionChunk,\n defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"\n ) {\n const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(\n delta,\n rawResponse,\n defaultRole\n );\n messageChunk.additional_kwargs.reasoning_content = delta.reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n messageChunk.response_metadata = {\n ...messageChunk.response_metadata,\n model_provider: \"deepseek\",\n };\n return messageChunk;\n }\n\n async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this[\"ParsedCallOptions\"],\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const stream = super._streamResponseChunks(messages, options, runManager);\n\n // State for parsing <think> tags\n let tokensBuffer = \"\";\n let isThinking = false;\n\n for await (const chunk of stream) {\n if (options.signal?.aborted) {\n return;\n }\n // If the model already provided reasoning_content natively, just yield it\n if (chunk.message.additional_kwargs.reasoning_content) {\n yield chunk;\n continue;\n }\n\n const text = chunk.text;\n if (!text) {\n yield chunk;\n continue;\n }\n\n // Append text to buffer to handle split tags\n tokensBuffer += text;\n\n // Check for <think> start tag\n if (!isThinking && tokensBuffer.includes(\"<think>\")) {\n isThinking = true;\n const thinkIndex = tokensBuffer.indexOf(\"<think>\");\n const beforeThink = tokensBuffer.substring(0, thinkIndex);\n const afterThink = tokensBuffer.substring(\n thinkIndex + \"<think>\".length\n );\n\n // We consumed up to <think>, so buffer becomes what's after\n tokensBuffer = afterThink || \"\"; // might be empty or part of thought\n\n if (beforeThink) {\n // Send the content before the tag\n const newChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: beforeThink,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: beforeThink,\n generationInfo: chunk.generationInfo,\n });\n yield newChunk;\n }\n }\n\n // Check for </think> end tag\n if (isThinking && tokensBuffer.includes(\"</think>\")) {\n isThinking = false;\n const thinkEndIndex = tokensBuffer.indexOf(\"</think>\");\n const thoughtContent = tokensBuffer.substring(0, thinkEndIndex);\n const afterThink = tokensBuffer.substring(\n thinkEndIndex + \"</think>\".length\n );\n\n // Yield the reasoning content\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: thoughtContent,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n\n // Reset buffer to what's after </think>\n tokensBuffer = afterThink || \"\";\n\n // Yield the rest as normal content if any\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\"; // consumed\n }\n } else if (isThinking) {\n // We are inside thinking block.\n // Check partial </think> match\n const possibleEndTag = \"</think>\";\n let splitIndex = -1;\n\n // Check if buffer ends with a prefix of </think> - Greedy check (longest first)\n for (let i = possibleEndTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleEndTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: safeToYield,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // content is safe to yield as reasoning\n if (tokensBuffer) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: {\n ...chunk.message.additional_kwargs,\n reasoning_content: tokensBuffer,\n },\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: \"\",\n generationInfo: chunk.generationInfo,\n });\n yield reasoningChunk;\n tokensBuffer = \"\";\n }\n }\n } else {\n // NOT thinking.\n // Check partial start tag \"<think>\" - Greedy check (longest first)\n const possibleStartTag = \"<think>\";\n let splitIndex = -1;\n for (let i = possibleStartTag.length - 1; i >= 1; i--) {\n if (tokensBuffer.endsWith(possibleStartTag.substring(0, i))) {\n splitIndex = tokensBuffer.length - i;\n break;\n }\n }\n\n if (splitIndex !== -1) {\n // Yield safe content\n const safeToYield = tokensBuffer.substring(0, splitIndex);\n if (safeToYield) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: safeToYield,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: safeToYield,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n }\n tokensBuffer = tokensBuffer.substring(splitIndex); // keep partial tag\n } else {\n // Yield all\n if (tokensBuffer) {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n additional_kwargs: chunk.message.additional_kwargs,\n response_metadata: chunk.message.response_metadata,\n tool_calls: chunk.message.tool_calls,\n tool_call_chunks: chunk.message.tool_call_chunks,\n id: chunk.message.id,\n }),\n text: tokensBuffer,\n generationInfo: chunk.generationInfo,\n });\n yield contentChunk;\n tokensBuffer = \"\";\n }\n }\n }\n }\n\n // Flush remaining buffer at end of stream\n if (tokensBuffer) {\n // If we were thinking, it's unclosed thought.\n if (isThinking) {\n const reasoningChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: \"\",\n additional_kwargs: { reasoning_content: tokensBuffer },\n }),\n text: \"\",\n });\n yield reasoningChunk;\n } else {\n const contentChunk = new ChatGenerationChunk({\n message: new AIMessageChunk({\n content: tokensBuffer,\n }),\n text: tokensBuffer,\n });\n yield contentChunk;\n }\n }\n }\n\n protected override _convertCompletionsMessageToBaseMessage(\n message: OpenAIClient.ChatCompletionMessage,\n rawResponse: OpenAIClient.ChatCompletion\n ) {\n const langChainMessage = super._convertCompletionsMessageToBaseMessage(\n message,\n rawResponse\n );\n langChainMessage.additional_kwargs.reasoning_content =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (message as any).reasoning_content;\n // Override model_provider for DeepSeek-specific block translation\n langChainMessage.response_metadata = {\n ...langChainMessage.response_metadata,\n model_provider: \"deepseek\",\n };\n return langChainMessage;\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatDeepSeek({ model: \"deepseek-chat\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // false\n * ```\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n const ensuredConfig = { ...config };\n // Deepseek does not support json schema yet\n if (ensuredConfig?.method === undefined) {\n ensuredConfig.method = \"functionCalling\";\n }\n return super.withStructuredOutput<RunOutput>(outputSchema, ensuredConfig);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAGJ,oBAAe,aAAa,UAAU,WAAW;eAG7C,cAAc;AAahB,WAZqB,IAAI,oBAAoB;MAC3C,SAAS,IAAI,eAAe;OAC1B,SAAS;OACT,mBAAmB,MAAM,QAAQ;OACjC,mBAAmB,MAAM,QAAQ;OACjC,YAAY,MAAM,QAAQ;OAC1B,kBAAkB,MAAM,QAAQ;OAChC,IAAI,MAAM,QAAQ;OACnB,CAAC;MACF,MAAM;MACN,gBAAgB,MAAM;MACvB,CAAC;AAEF,oBAAe;;;;AAOvB,MAAI,aAEF,KAAI,WAQF,OAPuB,IAAI,oBAAoB;GAC7C,SAAS,IAAI,eAAe;IAC1B,SAAS;IACT,mBAAmB,EAAE,mBAAmB,cAAc;IACvD,CAAC;GACF,MAAM;GACP,CAAC;MASF,OANqB,IAAI,oBAAoB;GAC3C,SAAS,IAAI,eAAe,EAC1B,SAAS,cACV,CAAC;GACF,MAAM;GACP,CAAC;;CAMR,AAAmB,wCACjB,SACA,aACA;EACA,MAAM,mBAAmB,MAAM,wCAC7B,SACA,YACD;AACD,mBAAiB,kBAAkB,oBAEhC,QAAgB;AAEnB,mBAAiB,oBAAoB;GACnC,GAAG,iBAAiB;GACpB,gBAAgB;GACjB;AACD,SAAO;;;;;;;;;;;;;;;;;;;CAoBT,IAAI,UAAwB;AAC1B,SAAO,SAAS,KAAK,UAAU,EAAE;;CAsCnC,qBAIE,cAIA,QAMI;EACJ,MAAM,gBAAgB,EAAE,GAAG,QAAQ;AAEnC,MAAI,eAAe,WAAW,OAC5B,eAAc,SAAS;AAEzB,SAAO,MAAM,qBAAgC,cAAc,cAAc"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_chat_models = require('./chat_models.cjs');
2
3
 
3
4
  exports.ChatDeepSeek = require_chat_models.ChatDeepSeek;
package/dist/profiles.cjs CHANGED
@@ -1,28 +1,28 @@
1
1
 
2
2
  //#region src/profiles.ts
3
3
  const PROFILES = {
4
- "deepseek-chat": {
4
+ "deepseek-reasoner": {
5
5
  maxInputTokens: 128e3,
6
6
  imageInputs: false,
7
7
  audioInputs: false,
8
8
  pdfInputs: false,
9
9
  videoInputs: false,
10
- maxOutputTokens: 8192,
11
- reasoningOutput: false,
10
+ maxOutputTokens: 128e3,
11
+ reasoningOutput: true,
12
12
  imageOutputs: false,
13
13
  audioOutputs: false,
14
14
  videoOutputs: false,
15
15
  toolCalling: true,
16
16
  structuredOutput: false
17
17
  },
18
- "deepseek-reasoner": {
18
+ "deepseek-chat": {
19
19
  maxInputTokens: 128e3,
20
20
  imageInputs: false,
21
21
  audioInputs: false,
22
22
  pdfInputs: false,
23
23
  videoInputs: false,
24
- maxOutputTokens: 128e3,
25
- reasoningOutput: true,
24
+ maxOutputTokens: 8192,
25
+ reasoningOutput: false,
26
26
  imageOutputs: false,
27
27
  audioOutputs: false,
28
28
  videoOutputs: false,
@@ -30,8 +30,7 @@ const PROFILES = {
30
30
  structuredOutput: false
31
31
  }
32
32
  };
33
- var profiles_default = PROFILES;
34
33
 
35
34
  //#endregion
36
- exports.default = profiles_default;
35
+ exports.default = PROFILES;
37
36
  //# sourceMappingURL=profiles.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.cjs","names":["PROFILES: Record<string, ModelProfile>"],"sources":["../src/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"deepseek-chat\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"deepseek-reasoner\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 128000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n};\nexport default PROFILES;\n"],"mappings":";;AAIA,MAAMA,WAAyC;CAC7C,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,qBAAqB;EACnB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;AACF;AACD,uBAAe"}
1
+ {"version":3,"file":"profiles.cjs","names":[],"sources":["../src/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"deepseek-reasoner\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 128000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"deepseek-chat\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n};\nexport default PROFILES;\n"],"mappings":";;AAIA,MAAM,WAAyC;CAC7C,qBAAqB;EACnB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACF"}
package/dist/profiles.js CHANGED
@@ -1,27 +1,27 @@
1
1
  //#region src/profiles.ts
2
2
  const PROFILES = {
3
- "deepseek-chat": {
3
+ "deepseek-reasoner": {
4
4
  maxInputTokens: 128e3,
5
5
  imageInputs: false,
6
6
  audioInputs: false,
7
7
  pdfInputs: false,
8
8
  videoInputs: false,
9
- maxOutputTokens: 8192,
10
- reasoningOutput: false,
9
+ maxOutputTokens: 128e3,
10
+ reasoningOutput: true,
11
11
  imageOutputs: false,
12
12
  audioOutputs: false,
13
13
  videoOutputs: false,
14
14
  toolCalling: true,
15
15
  structuredOutput: false
16
16
  },
17
- "deepseek-reasoner": {
17
+ "deepseek-chat": {
18
18
  maxInputTokens: 128e3,
19
19
  imageInputs: false,
20
20
  audioInputs: false,
21
21
  pdfInputs: false,
22
22
  videoInputs: false,
23
- maxOutputTokens: 128e3,
24
- reasoningOutput: true,
23
+ maxOutputTokens: 8192,
24
+ reasoningOutput: false,
25
25
  imageOutputs: false,
26
26
  audioOutputs: false,
27
27
  videoOutputs: false,
@@ -29,8 +29,7 @@ const PROFILES = {
29
29
  structuredOutput: false
30
30
  }
31
31
  };
32
- var profiles_default = PROFILES;
33
32
 
34
33
  //#endregion
35
- export { profiles_default as default };
34
+ export { PROFILES as default };
36
35
  //# sourceMappingURL=profiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.js","names":["PROFILES: Record<string, ModelProfile>"],"sources":["../src/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"deepseek-chat\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"deepseek-reasoner\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 128000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n};\nexport default PROFILES;\n"],"mappings":";AAIA,MAAMA,WAAyC;CAC7C,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,qBAAqB;EACnB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;AACF;AACD,uBAAe"}
1
+ {"version":3,"file":"profiles.js","names":[],"sources":["../src/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"deepseek-reasoner\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 128000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"deepseek-chat\": {\n maxInputTokens: 128000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n};\nexport default PROFILES;\n"],"mappings":";AAIA,MAAM,WAAyC;CAC7C,qBAAqB;EACnB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,iBAAiB;EACf,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/deepseek",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Deepseek integration for LangChain.js",
5
5
  "type": "module",
6
6
  "author": "LangChain",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-deepseek",
16
16
  "dependencies": {
17
- "@langchain/openai": "1.2.7"
17
+ "@langchain/openai": "1.2.8"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@langchain/core": "^1.0.0"
@@ -28,7 +28,7 @@
28
28
  "prettier": "^3.5.0",
29
29
  "typescript": "~5.8.3",
30
30
  "vitest": "^3.2.4",
31
- "@langchain/core": "^1.1.21",
31
+ "@langchain/core": "^1.1.25",
32
32
  "@langchain/eslint": "0.1.1",
33
33
  "@langchain/standard-tests": "0.0.23",
34
34
  "@langchain/tsconfig": "0.0.1"
@@ -1,25 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
-
25
- exports.__toESM = __toESM;