langchain 0.3.18 → 0.3.20

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.
@@ -20,6 +20,7 @@ const _SUPPORTED_PROVIDERS = [
20
20
  "bedrock",
21
21
  "cerebras",
22
22
  "deepseek",
23
+ "xai",
23
24
  ];
24
25
  async function _initChatModelHelper(model, modelProvider,
25
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -84,6 +85,10 @@ params = {}) {
84
85
  const { ChatDeepSeek } = await import("@langchain/deepseek");
85
86
  return new ChatDeepSeek({ model, ...passedParams });
86
87
  }
88
+ case "xai": {
89
+ const { ChatXAI } = await import("@langchain/xai");
90
+ return new ChatXAI({ model, ...passedParams });
91
+ }
87
92
  case "fireworks": {
88
93
  const { ChatFireworks } = await import(
89
94
  // We can not 'expect-error' because if you explicitly build `@langchain/community`
@@ -136,7 +141,8 @@ params = {}) {
136
141
  function _inferModelProvider(modelName) {
137
142
  if (modelName.startsWith("gpt-3") ||
138
143
  modelName.startsWith("gpt-4") ||
139
- modelName.startsWith("o1")) {
144
+ modelName.startsWith("o1") ||
145
+ modelName.startsWith("o3")) {
140
146
  return "openai";
141
147
  }
142
148
  else if (modelName.startsWith("claude")) {
@@ -402,6 +408,7 @@ class _ConfigurableModel extends chat_models_1.BaseChatModel {
402
408
  * - ollama (@langchain/ollama)
403
409
  * - cerebras (@langchain/cerebras)
404
410
  * - deepseek (@langchain/deepseek)
411
+ * - xai (@langchain/xai)
405
412
  * @param {string[] | "any"} [fields.configurableFields] - Which model parameters are configurable:
406
413
  * - undefined: No configurable fields.
407
414
  * - "any": All fields are configurable. (See Security Note in description)
@@ -9,7 +9,7 @@ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
9
9
  import { ChatResult } from "@langchain/core/outputs";
10
10
  interface EventStreamCallbackHandlerInput extends Omit<LogStreamCallbackHandlerInput, "_schemaFormat"> {
11
11
  }
12
- declare const _SUPPORTED_PROVIDERS: readonly ["openai", "anthropic", "azure_openai", "cohere", "google-vertexai", "google-vertexai-web", "google-genai", "ollama", "together", "fireworks", "mistralai", "groq", "bedrock", "cerebras", "deepseek"];
12
+ declare const _SUPPORTED_PROVIDERS: readonly ["openai", "anthropic", "azure_openai", "cohere", "google-vertexai", "google-vertexai-web", "google-genai", "ollama", "together", "fireworks", "mistralai", "groq", "bedrock", "cerebras", "deepseek", "xai"];
13
13
  export type ChatModelProvider = (typeof _SUPPORTED_PROVIDERS)[number];
14
14
  export interface ConfigurableChatModelCallOptions extends BaseChatModelCallOptions {
15
15
  tools?: (StructuredToolInterface | Record<string, unknown> | ToolDefinition | RunnableToolLike)[];
@@ -17,6 +17,7 @@ const _SUPPORTED_PROVIDERS = [
17
17
  "bedrock",
18
18
  "cerebras",
19
19
  "deepseek",
20
+ "xai",
20
21
  ];
21
22
  async function _initChatModelHelper(model, modelProvider,
22
23
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -81,6 +82,10 @@ params = {}) {
81
82
  const { ChatDeepSeek } = await import("@langchain/deepseek");
82
83
  return new ChatDeepSeek({ model, ...passedParams });
83
84
  }
85
+ case "xai": {
86
+ const { ChatXAI } = await import("@langchain/xai");
87
+ return new ChatXAI({ model, ...passedParams });
88
+ }
84
89
  case "fireworks": {
85
90
  const { ChatFireworks } = await import(
86
91
  // We can not 'expect-error' because if you explicitly build `@langchain/community`
@@ -133,7 +138,8 @@ params = {}) {
133
138
  export function _inferModelProvider(modelName) {
134
139
  if (modelName.startsWith("gpt-3") ||
135
140
  modelName.startsWith("gpt-4") ||
136
- modelName.startsWith("o1")) {
141
+ modelName.startsWith("o1") ||
142
+ modelName.startsWith("o3")) {
137
143
  return "openai";
138
144
  }
139
145
  else if (modelName.startsWith("claude")) {
@@ -398,6 +404,7 @@ class _ConfigurableModel extends BaseChatModel {
398
404
  * - ollama (@langchain/ollama)
399
405
  * - cerebras (@langchain/cerebras)
400
406
  * - deepseek (@langchain/deepseek)
407
+ * - xai (@langchain/xai)
401
408
  * @param {string[] | "any"} [fields.configurableFields] - Which model parameters are configurable:
402
409
  * - undefined: No configurable fields.
403
410
  * - "any": All fields are configurable. (See Security Note in description)
package/dist/hub/base.cjs CHANGED
@@ -74,7 +74,10 @@ modelClass) {
74
74
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
75
  const modelLcName = modelClass?.lc_name();
76
76
  let importMapKey;
77
- if (modelLcName === "ChatAnthropic") {
77
+ if (modelLcName === "ChatOpenAI") {
78
+ importMapKey = "chat_models__openai";
79
+ }
80
+ else if (modelLcName === "ChatAnthropic") {
78
81
  importMapKey = "chat_models__anthropic";
79
82
  }
80
83
  else if (modelLcName === "ChatAzureOpenAI") {
@@ -99,7 +102,7 @@ modelClass) {
99
102
  importMapKey = "chat_models__groq";
100
103
  }
101
104
  else {
102
- throw new Error("Received unsupport model class when pulling prompt.");
105
+ throw new Error("Received unsupported model class when pulling prompt.");
103
106
  }
104
107
  modelImportMap[importMapKey] = {
105
108
  ...modelImportMap[importMapKey],
package/dist/hub/base.js CHANGED
@@ -69,7 +69,10 @@ modelClass) {
69
69
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
70
  const modelLcName = modelClass?.lc_name();
71
71
  let importMapKey;
72
- if (modelLcName === "ChatAnthropic") {
72
+ if (modelLcName === "ChatOpenAI") {
73
+ importMapKey = "chat_models__openai";
74
+ }
75
+ else if (modelLcName === "ChatAnthropic") {
73
76
  importMapKey = "chat_models__anthropic";
74
77
  }
75
78
  else if (modelLcName === "ChatAzureOpenAI") {
@@ -94,7 +97,7 @@ modelClass) {
94
97
  importMapKey = "chat_models__groq";
95
98
  }
96
99
  else {
97
- throw new Error("Received unsupport model class when pulling prompt.");
100
+ throw new Error("Received unsupported model class when pulling prompt.");
98
101
  }
99
102
  modelImportMap[importMapKey] = {
100
103
  ...modelImportMap[importMapKey],
package/dist/hub/node.cjs CHANGED
@@ -20,7 +20,10 @@ async function pull(ownerRepoCommit, options) {
20
20
  if (options?.includeModel) {
21
21
  if (Array.isArray(promptObject.manifest.kwargs?.last?.kwargs?.bound?.id)) {
22
22
  const modelName = promptObject.manifest.kwargs?.last?.kwargs?.bound?.id.at(-1);
23
- if (modelName === "ChatAnthropic") {
23
+ if (modelName === "ChatOpenAI") {
24
+ modelClass = (await import("@langchain/openai")).ChatOpenAI;
25
+ }
26
+ else if (modelName === "ChatAnthropic") {
24
27
  modelClass = (await import("@langchain/anthropic")).ChatAnthropic;
25
28
  }
26
29
  else if (modelName === "ChatAzureOpenAI") {
package/dist/hub/node.js CHANGED
@@ -18,7 +18,10 @@ export async function pull(ownerRepoCommit, options) {
18
18
  if (options?.includeModel) {
19
19
  if (Array.isArray(promptObject.manifest.kwargs?.last?.kwargs?.bound?.id)) {
20
20
  const modelName = promptObject.manifest.kwargs?.last?.kwargs?.bound?.id.at(-1);
21
- if (modelName === "ChatAnthropic") {
21
+ if (modelName === "ChatOpenAI") {
22
+ modelClass = (await import("@langchain/openai")).ChatOpenAI;
23
+ }
24
+ else if (modelName === "ChatAnthropic") {
22
25
  modelClass = (await import("@langchain/anthropic")).ChatAnthropic;
23
26
  }
24
27
  else if (modelName === "ChatAzureOpenAI") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -428,6 +428,7 @@
428
428
  "@langchain/mistralai": "*",
429
429
  "@langchain/ollama": "*",
430
430
  "@langchain/scripts": ">=0.1.0 <0.2.0",
431
+ "@langchain/xai": "*",
431
432
  "@swc/core": "^1.3.90",
432
433
  "@swc/jest": "^0.2.29",
433
434
  "@tsconfig/recommended": "^1.0.2",
@@ -456,6 +457,7 @@
456
457
  "openai": "^4.41.1",
457
458
  "peggy": "^3.0.2",
458
459
  "prettier": "^2.8.3",
460
+ "reflect-metadata": "^0.2.2",
459
461
  "release-it": "^17.6.0",
460
462
  "rimraf": "^5.0.1",
461
463
  "rollup": "^3.19.1",
@@ -477,6 +479,7 @@
477
479
  "@langchain/groq": "*",
478
480
  "@langchain/mistralai": "*",
479
481
  "@langchain/ollama": "*",
482
+ "@langchain/xai": "*",
480
483
  "axios": "*",
481
484
  "cheerio": "*",
482
485
  "handlebars": "^4.7.8",
@@ -517,6 +520,9 @@
517
520
  "@langchain/ollama": {
518
521
  "optional": true
519
522
  },
523
+ "@langchain/xai": {
524
+ "optional": true
525
+ },
520
526
  "axios": {
521
527
  "optional": true
522
528
  },
@@ -534,7 +540,7 @@
534
540
  }
535
541
  },
536
542
  "dependencies": {
537
- "@langchain/openai": ">=0.1.0 <0.5.0",
543
+ "@langchain/openai": ">=0.1.0 <0.6.0",
538
544
  "@langchain/textsplitters": ">=0.0.0 <0.2.0",
539
545
  "js-tiktoken": "^1.0.12",
540
546
  "js-yaml": "^4.1.0",