langchain 0.3.24 → 0.3.26

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.
@@ -79,7 +79,7 @@ class ReActSingleInputOutputParser extends types_js_1.AgentActionOutputParser {
79
79
  }
80
80
  const action = actionMatch[1];
81
81
  const actionInput = actionMatch[2];
82
- const toolInput = actionInput.trim().replace(/"/g, "");
82
+ const toolInput = actionInput.trim().replace(/^"|"$/g, "");
83
83
  return {
84
84
  tool: action,
85
85
  toolInput,
@@ -76,7 +76,7 @@ export class ReActSingleInputOutputParser extends AgentActionOutputParser {
76
76
  }
77
77
  const action = actionMatch[1];
78
78
  const actionInput = actionMatch[2];
79
- const toolInput = actionInput.trim().replace(/"/g, "");
79
+ const toolInput = actionInput.trim().replace(/^"|"$/g, "");
80
80
  return {
81
81
  tool: action,
82
82
  toolInput,
@@ -12,4 +12,4 @@ export declare function createRetrieverTool(retriever: BaseRetrieverInterface, i
12
12
  input: string;
13
13
  }, {
14
14
  input: string;
15
- }>;
15
+ }, string>;
@@ -45,13 +45,15 @@ class XMLAgentOutputParser extends types_js_1.AgentActionOutputParser {
45
45
  */
46
46
  async parse(text) {
47
47
  if (text.includes("</tool>")) {
48
- const [tool, toolInput] = text.split("</tool>");
49
- const _tool = tool.split("<tool>")[1];
50
- const _toolInput = toolInput.split("<tool_input>")[1];
48
+ const _toolMatch = text.match(/<tool>([^<]*)<\/tool>/);
49
+ const _tool = _toolMatch ? _toolMatch[1] : "";
50
+ const _toolInputMatch = text.match(/<tool_input>([^<]*?)(?:<\/tool_input>|$)/);
51
+ const _toolInput = _toolInputMatch ? _toolInputMatch[1] : "";
51
52
  return { tool: _tool, toolInput: _toolInput, log: text };
52
53
  }
53
54
  else if (text.includes("<final_answer>")) {
54
- const [, answer] = text.split("<final_answer>");
55
+ const answerMatch = text.match(/<final_answer>([^<]*?)(?:<\/final_answer>|$)/);
56
+ const answer = answerMatch ? answerMatch[1] : "";
55
57
  return { returnValues: { output: answer }, log: text };
56
58
  }
57
59
  else {
@@ -42,13 +42,15 @@ export class XMLAgentOutputParser extends AgentActionOutputParser {
42
42
  */
43
43
  async parse(text) {
44
44
  if (text.includes("</tool>")) {
45
- const [tool, toolInput] = text.split("</tool>");
46
- const _tool = tool.split("<tool>")[1];
47
- const _toolInput = toolInput.split("<tool_input>")[1];
45
+ const _toolMatch = text.match(/<tool>([^<]*)<\/tool>/);
46
+ const _tool = _toolMatch ? _toolMatch[1] : "";
47
+ const _toolInputMatch = text.match(/<tool_input>([^<]*?)(?:<\/tool_input>|$)/);
48
+ const _toolInput = _toolInputMatch ? _toolInputMatch[1] : "";
48
49
  return { tool: _tool, toolInput: _toolInput, log: text };
49
50
  }
50
51
  else if (text.includes("<final_answer>")) {
51
- const [, answer] = text.split("<final_answer>");
52
+ const answerMatch = text.match(/<final_answer>([^<]*?)(?:<\/final_answer>|$)/);
53
+ const answer = answerMatch ? answerMatch[1] : "";
52
54
  return { returnValues: { output: answer }, log: text };
53
55
  }
54
56
  else {
@@ -90,6 +90,8 @@ params = {}) {
90
90
  return new ChatXAI({ model, ...passedParams });
91
91
  }
92
92
  case "fireworks": {
93
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
94
+ // @ts-ignore - Can not install as a proper dependency due to circular dependency
93
95
  const { ChatFireworks } = await import(
94
96
  // We can not 'expect-error' because if you explicitly build `@langchain/community`
95
97
  // this import will be able to be resolved, thus there will be no error. However
@@ -100,6 +102,8 @@ params = {}) {
100
102
  return new ChatFireworks({ model, ...passedParams });
101
103
  }
102
104
  case "together": {
105
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
106
+ // @ts-ignore - Can not install as a proper dependency due to circular dependency
103
107
  const { ChatTogetherAI } = await import(
104
108
  // We can not 'expect-error' because if you explicitly build `@langchain/community`
105
109
  // this import will be able to be resolved, thus there will be no error. However
@@ -87,6 +87,8 @@ params = {}) {
87
87
  return new ChatXAI({ model, ...passedParams });
88
88
  }
89
89
  case "fireworks": {
90
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
91
+ // @ts-ignore - Can not install as a proper dependency due to circular dependency
90
92
  const { ChatFireworks } = await import(
91
93
  // We can not 'expect-error' because if you explicitly build `@langchain/community`
92
94
  // this import will be able to be resolved, thus there will be no error. However
@@ -97,6 +99,8 @@ params = {}) {
97
99
  return new ChatFireworks({ model, ...passedParams });
98
100
  }
99
101
  case "together": {
102
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
103
+ // @ts-ignore - Can not install as a proper dependency due to circular dependency
100
104
  const { ChatTogetherAI } = await import(
101
105
  // We can not 'expect-error' because if you explicitly build `@langchain/community`
102
106
  // this import will be able to be resolved, thus there will be no error. However
package/dist/hub/base.cjs CHANGED
@@ -83,7 +83,7 @@ modelClass) {
83
83
  else if (modelLcName === "ChatAzureOpenAI") {
84
84
  importMapKey = "chat_models__openai";
85
85
  }
86
- else if (modelLcName === "ChatGoogleVertexAI") {
86
+ else if (modelLcName === "ChatVertexAI") {
87
87
  importMapKey = "chat_models__vertexai";
88
88
  }
89
89
  else if (modelLcName === "ChatGoogleGenerativeAI") {
package/dist/hub/base.js CHANGED
@@ -78,7 +78,7 @@ modelClass) {
78
78
  else if (modelLcName === "ChatAzureOpenAI") {
79
79
  importMapKey = "chat_models__openai";
80
80
  }
81
- else if (modelLcName === "ChatGoogleVertexAI") {
81
+ else if (modelLcName === "ChatVertexAI") {
82
82
  importMapKey = "chat_models__vertexai";
83
83
  }
84
84
  else if (modelLcName === "ChatGoogleGenerativeAI") {
package/dist/hub/node.cjs CHANGED
@@ -29,7 +29,7 @@ async function pull(ownerRepoCommit, options) {
29
29
  else if (modelName === "ChatAzureOpenAI") {
30
30
  modelClass = (await import("@langchain/openai")).AzureChatOpenAI;
31
31
  }
32
- else if (modelName === "ChatGoogleVertexAI") {
32
+ else if (modelName === "ChatVertexAI") {
33
33
  modelClass = (await import("@langchain/google-vertexai")).ChatVertexAI;
34
34
  }
35
35
  else if (modelName === "ChatGoogleGenerativeAI") {
package/dist/hub/node.js CHANGED
@@ -27,7 +27,7 @@ export async function pull(ownerRepoCommit, options) {
27
27
  else if (modelName === "ChatAzureOpenAI") {
28
28
  modelClass = (await import("@langchain/openai")).AzureChatOpenAI;
29
29
  }
30
- else if (modelName === "ChatGoogleVertexAI") {
30
+ else if (modelName === "ChatVertexAI") {
31
31
  modelClass = (await import("@langchain/google-vertexai")).ChatVertexAI;
32
32
  }
33
33
  else if (modelName === "ChatGoogleGenerativeAI") {
@@ -11,4 +11,4 @@ export declare function createRetrieverTool(retriever: BaseRetrieverInterface, i
11
11
  query: string;
12
12
  }, {
13
13
  query: string;
14
- }>;
14
+ }, string>;
@@ -177,13 +177,13 @@ class OpenAPISpec {
177
177
  static getCleanedOperationId(operation, path, method) {
178
178
  let { operationId } = operation;
179
179
  if (operationId === undefined) {
180
- const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/, "_");
180
+ const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/g, "_");
181
181
  operationId = `${updatedPath.startsWith("/") ? updatedPath.slice(1) : updatedPath}_${method}`;
182
182
  }
183
183
  return operationId
184
- .replaceAll("-", "_")
185
- .replaceAll(".", "_")
186
- .replaceAll("/", "_");
184
+ .replaceAll(/-/g, "_")
185
+ .replaceAll(/\./g, "_")
186
+ .replaceAll(/\//g, "_");
187
187
  }
188
188
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
189
  static alertUnsupportedSpec(document) {
@@ -151,13 +151,13 @@ export class OpenAPISpec {
151
151
  static getCleanedOperationId(operation, path, method) {
152
152
  let { operationId } = operation;
153
153
  if (operationId === undefined) {
154
- const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/, "_");
154
+ const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/g, "_");
155
155
  operationId = `${updatedPath.startsWith("/") ? updatedPath.slice(1) : updatedPath}_${method}`;
156
156
  }
157
157
  return operationId
158
- .replaceAll("-", "_")
159
- .replaceAll(".", "_")
160
- .replaceAll("/", "_");
158
+ .replaceAll(/-/g, "_")
159
+ .replaceAll(/\./g, "_")
160
+ .replaceAll(/\//g, "_");
161
161
  }
162
162
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
163
  static alertUnsupportedSpec(document) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -545,7 +545,7 @@
545
545
  "js-tiktoken": "^1.0.12",
546
546
  "js-yaml": "^4.1.0",
547
547
  "jsonpointer": "^5.0.1",
548
- "langsmith": "^0.3.16",
548
+ "langsmith": "^0.3.29",
549
549
  "openapi-types": "^12.1.3",
550
550
  "p-retry": "4",
551
551
  "uuid": "^10.0.0",