langchain 0.3.4 → 0.3.6
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/README.md +1 -1
- package/dist/agents/chat_convo/prompt.cjs +1 -1
- package/dist/agents/chat_convo/prompt.d.ts +1 -1
- package/dist/agents/chat_convo/prompt.js +1 -1
- package/dist/chat_models/universal.cjs +24 -17
- package/dist/chat_models/universal.js +24 -17
- package/dist/output_parsers/openai_functions.cjs +9 -4
- package/dist/output_parsers/openai_functions.js +10 -5
- package/dist/output_parsers/structured.cjs +6 -1
- package/dist/output_parsers/structured.js +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ LangChain is written in TypeScript and can be used in:
|
|
|
34
34
|
- **Reason**: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.)
|
|
35
35
|
|
|
36
36
|
This framework consists of several parts.
|
|
37
|
-
- **Open-source libraries**: Build your applications using LangChain's open-source [building blocks](https://js.langchain.com/docs/concepts
|
|
37
|
+
- **Open-source libraries**: Build your applications using LangChain's open-source [building blocks](https://js.langchain.com/docs/concepts/lcel), [components](https://js.langchain.com/docs/concepts), and [third-party integrations](https://js.langchain.com/docs/integrations/platforms/).
|
|
38
38
|
Use [LangGraph.js](https://js.langchain.com/docs/concepts/#langgraphjs) to build stateful agents with first-class streaming and human-in-the-loop support.
|
|
39
39
|
- **Productionization**: Use [LangSmith](https://docs.smith.langchain.com/) to inspect, monitor and evaluate your chains, so that you can continuously optimize and deploy with confidence.
|
|
40
40
|
- **Deployment**: Turn your LangGraph applications into production-ready APIs and Assistants with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/).
|
|
@@ -31,7 +31,7 @@ Use this if you want to respond directly and conversationally to the human. Mark
|
|
|
31
31
|
\`\`\`json
|
|
32
32
|
{{{{
|
|
33
33
|
"action": "Final Answer",
|
|
34
|
-
"action_input": string // You should put what you want to return to
|
|
34
|
+
"action_input": string // You should put what you want to return to user here and make sure to use valid json newline characters.
|
|
35
35
|
}}}}
|
|
36
36
|
\`\`\`
|
|
37
37
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const DEFAULT_PREFIX = "Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.";
|
|
2
2
|
export declare const PREFIX_END = " However, above all else, all responses must adhere to the format of RESPONSE FORMAT INSTRUCTIONS.";
|
|
3
|
-
export declare const FORMAT_INSTRUCTIONS = "RESPONSE FORMAT INSTRUCTIONS\n----------------------------\n\nOutput a JSON markdown code snippet containing a valid JSON object in one of two formats:\n\n**Option 1:**\nUse this if you want the human to use a tool.\nMarkdown code snippet formatted in the following schema:\n\n```json\n{{{{\n \"action\": string, // The action to take. Must be one of [{tool_names}]\n \"action_input\": string // The input to the action. May be a stringified object.\n}}}}\n```\n\n**Option #2:**\nUse this if you want to respond directly and conversationally to the human. Markdown code snippet formatted in the following schema:\n\n```json\n{{{{\n \"action\": \"Final Answer\",\n \"action_input\": string // You should put what you want to return to
|
|
3
|
+
export declare const FORMAT_INSTRUCTIONS = "RESPONSE FORMAT INSTRUCTIONS\n----------------------------\n\nOutput a JSON markdown code snippet containing a valid JSON object in one of two formats:\n\n**Option 1:**\nUse this if you want the human to use a tool.\nMarkdown code snippet formatted in the following schema:\n\n```json\n{{{{\n \"action\": string, // The action to take. Must be one of [{tool_names}]\n \"action_input\": string // The input to the action. May be a stringified object.\n}}}}\n```\n\n**Option #2:**\nUse this if you want to respond directly and conversationally to the human. Markdown code snippet formatted in the following schema:\n\n```json\n{{{{\n \"action\": \"Final Answer\",\n \"action_input\": string // You should put what you want to return to user here and make sure to use valid json newline characters.\n}}}}\n```\n\nFor both options, remember to always include the surrounding markdown code snippet delimiters (begin with \"```json\" and end with \"```\")!\n";
|
|
4
4
|
export declare const DEFAULT_SUFFIX = "TOOLS\n------\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\n\n{tools}\n\n{format_instructions}\n\nUSER'S INPUT\n--------------------\nHere is the user's input (remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\n\n{{input}}";
|
|
5
5
|
export declare const TEMPLATE_TOOL_RESPONSE = "TOOL RESPONSE:\n---------------------\n{observation}\n\nUSER'S INPUT\n--------------------\n\nOkay, so what is the response to my last comment? If using information obtained from the tools you must mention it explicitly without mentioning the tool names - I have forgotten all TOOL RESPONSES! Remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else.";
|
|
@@ -28,7 +28,7 @@ Use this if you want to respond directly and conversationally to the human. Mark
|
|
|
28
28
|
\`\`\`json
|
|
29
29
|
{{{{
|
|
30
30
|
"action": "Final Answer",
|
|
31
|
-
"action_input": string // You should put what you want to return to
|
|
31
|
+
"action_input": string // You should put what you want to return to user here and make sure to use valid json newline characters.
|
|
32
32
|
}}}}
|
|
33
33
|
\`\`\`
|
|
34
34
|
|
|
@@ -25,47 +25,48 @@ params = {}) {
|
|
|
25
25
|
if (!modelProviderCopy) {
|
|
26
26
|
throw new Error(`Unable to infer model provider for { model: ${model} }, please specify modelProvider directly.`);
|
|
27
27
|
}
|
|
28
|
+
const { modelProvider: _unused, ...passedParams } = params;
|
|
28
29
|
try {
|
|
29
30
|
switch (modelProviderCopy) {
|
|
30
31
|
case "openai": {
|
|
31
32
|
const { ChatOpenAI } = await import("@langchain/openai");
|
|
32
|
-
return new ChatOpenAI({ model, ...
|
|
33
|
+
return new ChatOpenAI({ model, ...passedParams });
|
|
33
34
|
}
|
|
34
35
|
case "anthropic": {
|
|
35
36
|
const { ChatAnthropic } = await import("@langchain/anthropic");
|
|
36
|
-
return new ChatAnthropic({ model, ...
|
|
37
|
+
return new ChatAnthropic({ model, ...passedParams });
|
|
37
38
|
}
|
|
38
39
|
case "azure_openai": {
|
|
39
40
|
const { AzureChatOpenAI } = await import("@langchain/openai");
|
|
40
|
-
return new AzureChatOpenAI({ model, ...
|
|
41
|
+
return new AzureChatOpenAI({ model, ...passedParams });
|
|
41
42
|
}
|
|
42
43
|
case "cohere": {
|
|
43
44
|
const { ChatCohere } = await import("@langchain/cohere");
|
|
44
|
-
return new ChatCohere({ model, ...
|
|
45
|
+
return new ChatCohere({ model, ...passedParams });
|
|
45
46
|
}
|
|
46
47
|
case "google-vertexai": {
|
|
47
48
|
const { ChatVertexAI } = await import("@langchain/google-vertexai");
|
|
48
|
-
return new ChatVertexAI({ model, ...
|
|
49
|
+
return new ChatVertexAI({ model, ...passedParams });
|
|
49
50
|
}
|
|
50
51
|
case "google-genai": {
|
|
51
52
|
const { ChatGoogleGenerativeAI } = await import("@langchain/google-genai");
|
|
52
|
-
return new ChatGoogleGenerativeAI({ model, ...
|
|
53
|
+
return new ChatGoogleGenerativeAI({ model, ...passedParams });
|
|
53
54
|
}
|
|
54
55
|
case "ollama": {
|
|
55
56
|
const { ChatOllama } = await import("@langchain/ollama");
|
|
56
|
-
return new ChatOllama({ model, ...
|
|
57
|
+
return new ChatOllama({ model, ...passedParams });
|
|
57
58
|
}
|
|
58
59
|
case "mistralai": {
|
|
59
60
|
const { ChatMistralAI } = await import("@langchain/mistralai");
|
|
60
|
-
return new ChatMistralAI({ model, ...
|
|
61
|
+
return new ChatMistralAI({ model, ...passedParams });
|
|
61
62
|
}
|
|
62
63
|
case "groq": {
|
|
63
64
|
const { ChatGroq } = await import("@langchain/groq");
|
|
64
|
-
return new ChatGroq({ model, ...
|
|
65
|
+
return new ChatGroq({ model, ...passedParams });
|
|
65
66
|
}
|
|
66
67
|
case "bedrock": {
|
|
67
68
|
const { ChatBedrockConverse } = await import("@langchain/aws");
|
|
68
|
-
return new ChatBedrockConverse({ model, ...
|
|
69
|
+
return new ChatBedrockConverse({ model, ...passedParams });
|
|
69
70
|
}
|
|
70
71
|
case "fireworks": {
|
|
71
72
|
const { ChatFireworks } = await import(
|
|
@@ -75,7 +76,7 @@ params = {}) {
|
|
|
75
76
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
77
|
// @ts-ignore - Can not install as a proper dependency due to circular dependency
|
|
77
78
|
"@langchain/community/chat_models/fireworks");
|
|
78
|
-
return new ChatFireworks({ model, ...
|
|
79
|
+
return new ChatFireworks({ model, ...passedParams });
|
|
79
80
|
}
|
|
80
81
|
case "together": {
|
|
81
82
|
const { ChatTogetherAI } = await import(
|
|
@@ -85,7 +86,7 @@ params = {}) {
|
|
|
85
86
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
87
|
// @ts-ignore - Can not install as a proper dependency due to circular dependency
|
|
87
88
|
"@langchain/community/chat_models/togetherai");
|
|
88
|
-
return new ChatTogetherAI({ model, ...
|
|
89
|
+
return new ChatTogetherAI({ model, ...passedParams });
|
|
89
90
|
}
|
|
90
91
|
default: {
|
|
91
92
|
const supported = _SUPPORTED_PROVIDERS.join(", ");
|
|
@@ -208,7 +209,10 @@ class _ConfigurableModel extends chat_models_1.BaseChatModel {
|
|
|
208
209
|
this._configurableFields = "any";
|
|
209
210
|
}
|
|
210
211
|
else {
|
|
211
|
-
this._configurableFields = fields.configurableFields ??
|
|
212
|
+
this._configurableFields = fields.configurableFields ?? [
|
|
213
|
+
"model",
|
|
214
|
+
"modelProvider",
|
|
215
|
+
];
|
|
212
216
|
}
|
|
213
217
|
if (fields.configPrefix) {
|
|
214
218
|
this._configPrefix = fields.configPrefix.endsWith("_")
|
|
@@ -289,6 +293,7 @@ class _ConfigurableModel extends chat_models_1.BaseChatModel {
|
|
|
289
293
|
? [...this._configurableFields]
|
|
290
294
|
: this._configurableFields,
|
|
291
295
|
configPrefix: this._configPrefix,
|
|
296
|
+
queuedMethodOperations: this._queuedMethodOperations,
|
|
292
297
|
});
|
|
293
298
|
return new runnables_1.RunnableBinding({
|
|
294
299
|
config: mergedConfig,
|
|
@@ -562,18 +567,20 @@ fields) {
|
|
|
562
567
|
configPrefix: "",
|
|
563
568
|
...(fields ?? {}),
|
|
564
569
|
};
|
|
565
|
-
let configurableFieldsCopy = configurableFields
|
|
566
|
-
|
|
570
|
+
let configurableFieldsCopy = Array.isArray(configurableFields)
|
|
571
|
+
? [...configurableFields]
|
|
572
|
+
: configurableFields;
|
|
573
|
+
if (!model && configurableFieldsCopy === undefined) {
|
|
567
574
|
configurableFieldsCopy = ["model", "modelProvider"];
|
|
568
575
|
}
|
|
569
|
-
if (configPrefix &&
|
|
576
|
+
if (configPrefix && configurableFieldsCopy === undefined) {
|
|
570
577
|
console.warn(`{ configPrefix: ${configPrefix} } has been set but no fields are configurable. Set ` +
|
|
571
578
|
`{ configurableFields: [...] } to specify the model params that are ` +
|
|
572
579
|
`configurable.`);
|
|
573
580
|
}
|
|
574
581
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
575
582
|
const paramsCopy = { ...params };
|
|
576
|
-
if (
|
|
583
|
+
if (configurableFieldsCopy === undefined) {
|
|
577
584
|
return new _ConfigurableModel({
|
|
578
585
|
defaultConfig: {
|
|
579
586
|
...paramsCopy,
|
|
@@ -22,47 +22,48 @@ params = {}) {
|
|
|
22
22
|
if (!modelProviderCopy) {
|
|
23
23
|
throw new Error(`Unable to infer model provider for { model: ${model} }, please specify modelProvider directly.`);
|
|
24
24
|
}
|
|
25
|
+
const { modelProvider: _unused, ...passedParams } = params;
|
|
25
26
|
try {
|
|
26
27
|
switch (modelProviderCopy) {
|
|
27
28
|
case "openai": {
|
|
28
29
|
const { ChatOpenAI } = await import("@langchain/openai");
|
|
29
|
-
return new ChatOpenAI({ model, ...
|
|
30
|
+
return new ChatOpenAI({ model, ...passedParams });
|
|
30
31
|
}
|
|
31
32
|
case "anthropic": {
|
|
32
33
|
const { ChatAnthropic } = await import("@langchain/anthropic");
|
|
33
|
-
return new ChatAnthropic({ model, ...
|
|
34
|
+
return new ChatAnthropic({ model, ...passedParams });
|
|
34
35
|
}
|
|
35
36
|
case "azure_openai": {
|
|
36
37
|
const { AzureChatOpenAI } = await import("@langchain/openai");
|
|
37
|
-
return new AzureChatOpenAI({ model, ...
|
|
38
|
+
return new AzureChatOpenAI({ model, ...passedParams });
|
|
38
39
|
}
|
|
39
40
|
case "cohere": {
|
|
40
41
|
const { ChatCohere } = await import("@langchain/cohere");
|
|
41
|
-
return new ChatCohere({ model, ...
|
|
42
|
+
return new ChatCohere({ model, ...passedParams });
|
|
42
43
|
}
|
|
43
44
|
case "google-vertexai": {
|
|
44
45
|
const { ChatVertexAI } = await import("@langchain/google-vertexai");
|
|
45
|
-
return new ChatVertexAI({ model, ...
|
|
46
|
+
return new ChatVertexAI({ model, ...passedParams });
|
|
46
47
|
}
|
|
47
48
|
case "google-genai": {
|
|
48
49
|
const { ChatGoogleGenerativeAI } = await import("@langchain/google-genai");
|
|
49
|
-
return new ChatGoogleGenerativeAI({ model, ...
|
|
50
|
+
return new ChatGoogleGenerativeAI({ model, ...passedParams });
|
|
50
51
|
}
|
|
51
52
|
case "ollama": {
|
|
52
53
|
const { ChatOllama } = await import("@langchain/ollama");
|
|
53
|
-
return new ChatOllama({ model, ...
|
|
54
|
+
return new ChatOllama({ model, ...passedParams });
|
|
54
55
|
}
|
|
55
56
|
case "mistralai": {
|
|
56
57
|
const { ChatMistralAI } = await import("@langchain/mistralai");
|
|
57
|
-
return new ChatMistralAI({ model, ...
|
|
58
|
+
return new ChatMistralAI({ model, ...passedParams });
|
|
58
59
|
}
|
|
59
60
|
case "groq": {
|
|
60
61
|
const { ChatGroq } = await import("@langchain/groq");
|
|
61
|
-
return new ChatGroq({ model, ...
|
|
62
|
+
return new ChatGroq({ model, ...passedParams });
|
|
62
63
|
}
|
|
63
64
|
case "bedrock": {
|
|
64
65
|
const { ChatBedrockConverse } = await import("@langchain/aws");
|
|
65
|
-
return new ChatBedrockConverse({ model, ...
|
|
66
|
+
return new ChatBedrockConverse({ model, ...passedParams });
|
|
66
67
|
}
|
|
67
68
|
case "fireworks": {
|
|
68
69
|
const { ChatFireworks } = await import(
|
|
@@ -72,7 +73,7 @@ params = {}) {
|
|
|
72
73
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
73
74
|
// @ts-ignore - Can not install as a proper dependency due to circular dependency
|
|
74
75
|
"@langchain/community/chat_models/fireworks");
|
|
75
|
-
return new ChatFireworks({ model, ...
|
|
76
|
+
return new ChatFireworks({ model, ...passedParams });
|
|
76
77
|
}
|
|
77
78
|
case "together": {
|
|
78
79
|
const { ChatTogetherAI } = await import(
|
|
@@ -82,7 +83,7 @@ params = {}) {
|
|
|
82
83
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
83
84
|
// @ts-ignore - Can not install as a proper dependency due to circular dependency
|
|
84
85
|
"@langchain/community/chat_models/togetherai");
|
|
85
|
-
return new ChatTogetherAI({ model, ...
|
|
86
|
+
return new ChatTogetherAI({ model, ...passedParams });
|
|
86
87
|
}
|
|
87
88
|
default: {
|
|
88
89
|
const supported = _SUPPORTED_PROVIDERS.join(", ");
|
|
@@ -204,7 +205,10 @@ class _ConfigurableModel extends BaseChatModel {
|
|
|
204
205
|
this._configurableFields = "any";
|
|
205
206
|
}
|
|
206
207
|
else {
|
|
207
|
-
this._configurableFields = fields.configurableFields ??
|
|
208
|
+
this._configurableFields = fields.configurableFields ?? [
|
|
209
|
+
"model",
|
|
210
|
+
"modelProvider",
|
|
211
|
+
];
|
|
208
212
|
}
|
|
209
213
|
if (fields.configPrefix) {
|
|
210
214
|
this._configPrefix = fields.configPrefix.endsWith("_")
|
|
@@ -285,6 +289,7 @@ class _ConfigurableModel extends BaseChatModel {
|
|
|
285
289
|
? [...this._configurableFields]
|
|
286
290
|
: this._configurableFields,
|
|
287
291
|
configPrefix: this._configPrefix,
|
|
292
|
+
queuedMethodOperations: this._queuedMethodOperations,
|
|
288
293
|
});
|
|
289
294
|
return new RunnableBinding({
|
|
290
295
|
config: mergedConfig,
|
|
@@ -558,18 +563,20 @@ fields) {
|
|
|
558
563
|
configPrefix: "",
|
|
559
564
|
...(fields ?? {}),
|
|
560
565
|
};
|
|
561
|
-
let configurableFieldsCopy = configurableFields
|
|
562
|
-
|
|
566
|
+
let configurableFieldsCopy = Array.isArray(configurableFields)
|
|
567
|
+
? [...configurableFields]
|
|
568
|
+
: configurableFields;
|
|
569
|
+
if (!model && configurableFieldsCopy === undefined) {
|
|
563
570
|
configurableFieldsCopy = ["model", "modelProvider"];
|
|
564
571
|
}
|
|
565
|
-
if (configPrefix &&
|
|
572
|
+
if (configPrefix && configurableFieldsCopy === undefined) {
|
|
566
573
|
console.warn(`{ configPrefix: ${configPrefix} } has been set but no fields are configurable. Set ` +
|
|
567
574
|
`{ configurableFields: [...] } to specify the model params that are ` +
|
|
568
575
|
`configurable.`);
|
|
569
576
|
}
|
|
570
577
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
571
578
|
const paramsCopy = { ...params };
|
|
572
|
-
if (
|
|
579
|
+
if (configurableFieldsCopy === undefined) {
|
|
573
580
|
return new _ConfigurableModel({
|
|
574
581
|
defaultConfig: {
|
|
575
582
|
...paramsCopy,
|
|
@@ -137,12 +137,17 @@ class JsonOutputFunctionsParser extends output_parsers_1.BaseCumulativeTransform
|
|
|
137
137
|
return this.parse(result);
|
|
138
138
|
}
|
|
139
139
|
async parse(text) {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
try {
|
|
141
|
+
const parsedResult = JSON.parse(text);
|
|
142
|
+
if (this.argsOnly) {
|
|
143
|
+
return parsedResult;
|
|
144
|
+
}
|
|
145
|
+
parsedResult.arguments = JSON.parse(parsedResult.arguments);
|
|
142
146
|
return parsedResult;
|
|
143
147
|
}
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
catch (e) {
|
|
149
|
+
throw new output_parsers_1.OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
|
|
150
|
+
}
|
|
146
151
|
}
|
|
147
152
|
getFormatInstructions() {
|
|
148
153
|
return "";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compare, } from "@langchain/core/utils/json_patch";
|
|
2
|
-
import { BaseCumulativeTransformOutputParser, BaseLLMOutputParser, } from "@langchain/core/output_parsers";
|
|
2
|
+
import { BaseCumulativeTransformOutputParser, BaseLLMOutputParser, OutputParserException, } from "@langchain/core/output_parsers";
|
|
3
3
|
import { parsePartialJson } from "@langchain/core/output_parsers";
|
|
4
4
|
/**
|
|
5
5
|
* Class for parsing the output of an LLM. Can be configured to return
|
|
@@ -133,12 +133,17 @@ export class JsonOutputFunctionsParser extends BaseCumulativeTransformOutputPars
|
|
|
133
133
|
return this.parse(result);
|
|
134
134
|
}
|
|
135
135
|
async parse(text) {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
try {
|
|
137
|
+
const parsedResult = JSON.parse(text);
|
|
138
|
+
if (this.argsOnly) {
|
|
139
|
+
return parsedResult;
|
|
140
|
+
}
|
|
141
|
+
parsedResult.arguments = JSON.parse(parsedResult.arguments);
|
|
138
142
|
return parsedResult;
|
|
139
143
|
}
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
catch (e) {
|
|
145
|
+
throw new OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
|
|
146
|
+
}
|
|
142
147
|
}
|
|
143
148
|
getFormatInstructions() {
|
|
144
149
|
return "";
|
|
@@ -80,7 +80,12 @@ ${JSON.stringify((0, zod_to_json_schema_1.zodToJsonSchema)(this.schema))}
|
|
|
80
80
|
return await this.schema.parseAsync(JSON.parse(json));
|
|
81
81
|
}
|
|
82
82
|
catch (e) {
|
|
83
|
-
|
|
83
|
+
try {
|
|
84
|
+
return await this.schema.parseAsync(JSON.parse(text.trim()));
|
|
85
|
+
}
|
|
86
|
+
catch (e2) {
|
|
87
|
+
throw new output_parsers_1.OutputParserException(`Failed to parse. Text: "${text}". Error: ${e2}`, text);
|
|
88
|
+
}
|
|
84
89
|
}
|
|
85
90
|
}
|
|
86
91
|
}
|
|
@@ -77,7 +77,12 @@ ${JSON.stringify(zodToJsonSchema(this.schema))}
|
|
|
77
77
|
return await this.schema.parseAsync(JSON.parse(json));
|
|
78
78
|
}
|
|
79
79
|
catch (e) {
|
|
80
|
-
|
|
80
|
+
try {
|
|
81
|
+
return await this.schema.parseAsync(JSON.parse(text.trim()));
|
|
82
|
+
}
|
|
83
|
+
catch (e2) {
|
|
84
|
+
throw new OutputParserException(`Failed to parse. Text: "${text}". Error: ${e2}`, text);
|
|
85
|
+
}
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
}
|