@langchain/anthropic 0.3.26 → 1.0.0-alpha.1
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 +8 -8
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/chat_models.cjs +772 -1000
- package/dist/chat_models.cjs.map +1 -0
- package/dist/chat_models.d.cts +615 -0
- package/dist/chat_models.d.cts.map +1 -0
- package/dist/chat_models.d.ts +222 -206
- package/dist/chat_models.d.ts.map +1 -0
- package/dist/chat_models.js +766 -991
- package/dist/chat_models.js.map +1 -0
- package/dist/index.cjs +6 -20
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -2
- package/dist/output_parsers.cjs +65 -104
- package/dist/output_parsers.cjs.map +1 -0
- package/dist/output_parsers.js +64 -100
- package/dist/output_parsers.js.map +1 -0
- package/dist/types.d.cts +32 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +29 -31
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/content.cjs +153 -0
- package/dist/utils/content.cjs.map +1 -0
- package/dist/utils/content.js +148 -0
- package/dist/utils/content.js.map +1 -0
- package/dist/utils/errors.cjs +16 -27
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/errors.js +17 -25
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.cjs +7 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/message_inputs.cjs +218 -535
- package/dist/utils/message_inputs.cjs.map +1 -0
- package/dist/utils/message_inputs.js +219 -533
- package/dist/utils/message_inputs.js.map +1 -0
- package/dist/utils/message_outputs.cjs +185 -246
- package/dist/utils/message_outputs.cjs.map +1 -0
- package/dist/utils/message_outputs.js +184 -243
- package/dist/utils/message_outputs.js.map +1 -0
- package/dist/utils/prompts.cjs +46 -45
- package/dist/utils/prompts.cjs.map +1 -0
- package/dist/utils/prompts.d.cts +45 -0
- package/dist/utils/prompts.d.cts.map +1 -0
- package/dist/utils/prompts.d.ts +8 -2
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +46 -42
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/standard.cjs +127 -0
- package/dist/utils/standard.cjs.map +1 -0
- package/dist/utils/standard.js +127 -0
- package/dist/utils/standard.js.map +1 -0
- package/dist/utils/tools.cjs +14 -25
- package/dist/utils/tools.cjs.map +1 -0
- package/dist/utils/tools.js +14 -23
- package/dist/utils/tools.js.map +1 -0
- package/package.json +30 -53
- package/dist/experimental/index.cjs +0 -17
- package/dist/experimental/index.d.ts +0 -1
- package/dist/experimental/index.js +0 -1
- package/dist/experimental/tool_calling.cjs +0 -318
- package/dist/experimental/tool_calling.d.ts +0 -57
- package/dist/experimental/tool_calling.js +0 -314
- package/dist/experimental/utils/tool_calling.cjs +0 -106
- package/dist/experimental/utils/tool_calling.d.ts +0 -10
- package/dist/experimental/utils/tool_calling.js +0 -101
- package/dist/load/import_constants.cjs +0 -5
- package/dist/load/import_constants.d.ts +0 -1
- package/dist/load/import_constants.js +0 -2
- package/dist/load/import_map.cjs +0 -39
- package/dist/load/import_map.d.ts +0 -2
- package/dist/load/import_map.js +0 -3
- package/dist/load/import_type.cjs +0 -3
- package/dist/load/import_type.d.ts +0 -5
- package/dist/load/import_type.js +0 -2
- package/dist/load/index.cjs +0 -63
- package/dist/load/index.d.ts +0 -14
- package/dist/load/index.js +0 -25
- package/dist/load/map_keys.cjs +0 -2
- package/dist/load/map_keys.d.ts +0 -3
- package/dist/load/map_keys.js +0 -1
- package/dist/load/serializable.cjs +0 -17
- package/dist/load/serializable.d.ts +0 -1
- package/dist/load/serializable.js +0 -1
- package/dist/output_parsers.d.ts +0 -22
- package/dist/types.cjs +0 -48
- package/dist/types.js +0 -45
- package/dist/utils/errors.d.ts +0 -3
- package/dist/utils/message_inputs.d.ts +0 -14
- package/dist/utils/message_outputs.d.ts +0 -14
- package/dist/utils/tools.d.ts +0 -3
- package/experimental.cjs +0 -1
- package/experimental.d.cts +0 -1
- package/experimental.d.ts +0 -1
- package/experimental.js +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_TOOL_SYSTEM_PROMPT = void 0;
|
|
4
|
-
exports.formatAsXMLRepresentation = formatAsXMLRepresentation;
|
|
5
|
-
exports.fixArrayXMLParameters = fixArrayXMLParameters;
|
|
6
|
-
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
7
|
-
const prompts_1 = require("@langchain/core/prompts");
|
|
8
|
-
exports.DEFAULT_TOOL_SYSTEM_PROMPT =
|
|
9
|
-
/* #__PURE__ */ prompts_1.PromptTemplate.fromTemplate(`In this environment you have access to a set of tools you can use to answer the user's question.
|
|
10
|
-
|
|
11
|
-
You may call them like this:
|
|
12
|
-
<function_calls>
|
|
13
|
-
<invoke>
|
|
14
|
-
<tool_name>$TOOL_NAME</tool_name>
|
|
15
|
-
<parameters>
|
|
16
|
-
<$PARAMETER_NAME>$PARAMETER_VALUE</$PARAMETER_NAME>
|
|
17
|
-
...
|
|
18
|
-
</parameters>
|
|
19
|
-
</invoke>
|
|
20
|
-
</function_calls>
|
|
21
|
-
|
|
22
|
-
Here are the tools available:
|
|
23
|
-
{tools}
|
|
24
|
-
|
|
25
|
-
If the schema above contains a property typed as an enum, you must only return values matching an allowed value for that enum.`);
|
|
26
|
-
function formatAsXMLRepresentation(tool) {
|
|
27
|
-
const builder = new fast_xml_parser_1.XMLBuilder();
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
const toolParamProps = tool.function.parameters?.properties;
|
|
30
|
-
const parameterXml = Object.keys(toolParamProps)
|
|
31
|
-
.map((key) => {
|
|
32
|
-
const parameterData = toolParamProps[key];
|
|
33
|
-
let xml = `<parameter>
|
|
34
|
-
<name>${key}</name>
|
|
35
|
-
<type>${parameterData.type}</type>`;
|
|
36
|
-
if (parameterData.description) {
|
|
37
|
-
xml += `\n<description>${parameterData.description}</description>`;
|
|
38
|
-
}
|
|
39
|
-
if (parameterData.type === "array" && parameterData.items) {
|
|
40
|
-
xml += `\n<items>${builder.build(parameterData.items.properties)}</items>`;
|
|
41
|
-
}
|
|
42
|
-
if (parameterData.properties) {
|
|
43
|
-
xml += `\n<properties>\n${builder.build(parameterData.properties)}\n</properties>`;
|
|
44
|
-
}
|
|
45
|
-
return `${xml}\n</parameter>`;
|
|
46
|
-
})
|
|
47
|
-
.join("\n");
|
|
48
|
-
return `<tool_description>
|
|
49
|
-
<tool_name>${tool.function.name}</tool_name>
|
|
50
|
-
<description>${tool.function.description}</description>
|
|
51
|
-
<parameters>
|
|
52
|
-
${parameterXml}
|
|
53
|
-
</parameters>
|
|
54
|
-
</tool_description>`;
|
|
55
|
-
}
|
|
56
|
-
function fixArrayXMLParameters(schema,
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
xmlParameters
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
-
) {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
const fixedParameters = {};
|
|
63
|
-
for (const key of Object.keys(xmlParameters)) {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
const schemaType = schema.properties[key].type;
|
|
66
|
-
// Crawl for lists indistinguishable from single items
|
|
67
|
-
if (schema.properties && schema.properties[key] && schemaType === "array") {
|
|
68
|
-
const value = xmlParameters[key];
|
|
69
|
-
if (Array.isArray(value)) {
|
|
70
|
-
fixedParameters[key] = value;
|
|
71
|
-
}
|
|
72
|
-
else if (typeof value === "string") {
|
|
73
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
74
|
-
fixedParameters[key] = JSON.parse(value);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
fixedParameters[key] = value.split(",");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
fixedParameters[key] = [value];
|
|
82
|
-
}
|
|
83
|
-
// Crawl for objects like {"item": "my string"} that should really just be "my string"
|
|
84
|
-
if (schemaType !== "object" &&
|
|
85
|
-
typeof xmlParameters[key] === "object" &&
|
|
86
|
-
!Array.isArray(xmlParameters[key]) &&
|
|
87
|
-
Object.keys(xmlParameters[key]).length === 1) {
|
|
88
|
-
// eslint-disable-next-line prefer-destructuring
|
|
89
|
-
fixedParameters[key] = Object.values(xmlParameters[key])[0];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (typeof xmlParameters[key] === "object" &&
|
|
93
|
-
xmlParameters[key] !== null) {
|
|
94
|
-
fixedParameters[key] = fixArrayXMLParameters({
|
|
95
|
-
...schema.properties[key],
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
-
definitions: schema.definitions,
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
}, xmlParameters[key]);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
fixedParameters[key] = xmlParameters[key];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return fixedParameters;
|
|
106
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type JsonSchema7ObjectType } from "@langchain/core/utils/json_schema";
|
|
2
|
-
import { PromptTemplate } from "@langchain/core/prompts";
|
|
3
|
-
import { ToolDefinition } from "@langchain/core/language_models/base";
|
|
4
|
-
export declare const DEFAULT_TOOL_SYSTEM_PROMPT: PromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"In this environment you have access to a set of tools you can use to answer the user's question.\n\nYou may call them like this:\n<function_calls>\n<invoke>\n<tool_name>$TOOL_NAME</tool_name>\n<parameters>\n<$PARAMETER_NAME>$PARAMETER_VALUE</$PARAMETER_NAME>\n...\n</parameters>\n</invoke>\n</function_calls>\n\nHere are the tools available:\n{tools}\n\nIf the schema above contains a property typed as an enum, you must only return values matching an allowed value for that enum.">, any>;
|
|
5
|
-
export type ToolInvocation = {
|
|
6
|
-
tool_name: string;
|
|
7
|
-
parameters: Record<string, unknown>;
|
|
8
|
-
};
|
|
9
|
-
export declare function formatAsXMLRepresentation(tool: ToolDefinition): string;
|
|
10
|
-
export declare function fixArrayXMLParameters(schema: JsonSchema7ObjectType, xmlParameters: Record<string, any>): Record<string, any>;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { XMLBuilder } from "fast-xml-parser";
|
|
2
|
-
import { PromptTemplate } from "@langchain/core/prompts";
|
|
3
|
-
export const DEFAULT_TOOL_SYSTEM_PROMPT =
|
|
4
|
-
/* #__PURE__ */ PromptTemplate.fromTemplate(`In this environment you have access to a set of tools you can use to answer the user's question.
|
|
5
|
-
|
|
6
|
-
You may call them like this:
|
|
7
|
-
<function_calls>
|
|
8
|
-
<invoke>
|
|
9
|
-
<tool_name>$TOOL_NAME</tool_name>
|
|
10
|
-
<parameters>
|
|
11
|
-
<$PARAMETER_NAME>$PARAMETER_VALUE</$PARAMETER_NAME>
|
|
12
|
-
...
|
|
13
|
-
</parameters>
|
|
14
|
-
</invoke>
|
|
15
|
-
</function_calls>
|
|
16
|
-
|
|
17
|
-
Here are the tools available:
|
|
18
|
-
{tools}
|
|
19
|
-
|
|
20
|
-
If the schema above contains a property typed as an enum, you must only return values matching an allowed value for that enum.`);
|
|
21
|
-
export function formatAsXMLRepresentation(tool) {
|
|
22
|
-
const builder = new XMLBuilder();
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
const toolParamProps = tool.function.parameters?.properties;
|
|
25
|
-
const parameterXml = Object.keys(toolParamProps)
|
|
26
|
-
.map((key) => {
|
|
27
|
-
const parameterData = toolParamProps[key];
|
|
28
|
-
let xml = `<parameter>
|
|
29
|
-
<name>${key}</name>
|
|
30
|
-
<type>${parameterData.type}</type>`;
|
|
31
|
-
if (parameterData.description) {
|
|
32
|
-
xml += `\n<description>${parameterData.description}</description>`;
|
|
33
|
-
}
|
|
34
|
-
if (parameterData.type === "array" && parameterData.items) {
|
|
35
|
-
xml += `\n<items>${builder.build(parameterData.items.properties)}</items>`;
|
|
36
|
-
}
|
|
37
|
-
if (parameterData.properties) {
|
|
38
|
-
xml += `\n<properties>\n${builder.build(parameterData.properties)}\n</properties>`;
|
|
39
|
-
}
|
|
40
|
-
return `${xml}\n</parameter>`;
|
|
41
|
-
})
|
|
42
|
-
.join("\n");
|
|
43
|
-
return `<tool_description>
|
|
44
|
-
<tool_name>${tool.function.name}</tool_name>
|
|
45
|
-
<description>${tool.function.description}</description>
|
|
46
|
-
<parameters>
|
|
47
|
-
${parameterXml}
|
|
48
|
-
</parameters>
|
|
49
|
-
</tool_description>`;
|
|
50
|
-
}
|
|
51
|
-
export function fixArrayXMLParameters(schema,
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
-
xmlParameters
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
) {
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
const fixedParameters = {};
|
|
58
|
-
for (const key of Object.keys(xmlParameters)) {
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
-
const schemaType = schema.properties[key].type;
|
|
61
|
-
// Crawl for lists indistinguishable from single items
|
|
62
|
-
if (schema.properties && schema.properties[key] && schemaType === "array") {
|
|
63
|
-
const value = xmlParameters[key];
|
|
64
|
-
if (Array.isArray(value)) {
|
|
65
|
-
fixedParameters[key] = value;
|
|
66
|
-
}
|
|
67
|
-
else if (typeof value === "string") {
|
|
68
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
69
|
-
fixedParameters[key] = JSON.parse(value);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
fixedParameters[key] = value.split(",");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
fixedParameters[key] = [value];
|
|
77
|
-
}
|
|
78
|
-
// Crawl for objects like {"item": "my string"} that should really just be "my string"
|
|
79
|
-
if (schemaType !== "object" &&
|
|
80
|
-
typeof xmlParameters[key] === "object" &&
|
|
81
|
-
!Array.isArray(xmlParameters[key]) &&
|
|
82
|
-
Object.keys(xmlParameters[key]).length === 1) {
|
|
83
|
-
// eslint-disable-next-line prefer-destructuring
|
|
84
|
-
fixedParameters[key] = Object.values(xmlParameters[key])[0];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else if (typeof xmlParameters[key] === "object" &&
|
|
88
|
-
xmlParameters[key] !== null) {
|
|
89
|
-
fixedParameters[key] = fixArrayXMLParameters({
|
|
90
|
-
...schema.properties[key],
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
definitions: schema.definitions,
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
}, xmlParameters[key]);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
fixedParameters[key] = xmlParameters[key];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return fixedParameters;
|
|
101
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const optionalImportEntrypoints: string[];
|
package/dist/load/import_map.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Auto-generated by build script. Do not edit manually.
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.experimental = exports.index = void 0;
|
|
38
|
-
exports.index = __importStar(require("../index.cjs"));
|
|
39
|
-
exports.experimental = __importStar(require("../experimental/index.cjs"));
|
package/dist/load/import_map.js
DELETED
package/dist/load/import_type.js
DELETED
package/dist/load/index.cjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.importMap = exports.optionalImportEntrypoints = void 0;
|
|
37
|
-
exports.load = load;
|
|
38
|
-
const load_1 = require("@langchain/core/load");
|
|
39
|
-
const importMap = __importStar(require("./import_map.cjs"));
|
|
40
|
-
exports.importMap = importMap;
|
|
41
|
-
const import_constants_js_1 = require("./import_constants.cjs");
|
|
42
|
-
Object.defineProperty(exports, "optionalImportEntrypoints", { enumerable: true, get: function () { return import_constants_js_1.optionalImportEntrypoints; } });
|
|
43
|
-
/**
|
|
44
|
-
* Load a LangChain module from a serialized text representation.
|
|
45
|
-
* NOTE: This functionality is currently in beta.
|
|
46
|
-
* Loaded classes may change independently of semver.
|
|
47
|
-
* @param text Serialized text representation of the module.
|
|
48
|
-
* @param secretsMap
|
|
49
|
-
* @param optionalImportsMap
|
|
50
|
-
* @returns A loaded instance of a LangChain module.
|
|
51
|
-
*/
|
|
52
|
-
async function load(text,
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
secretsMap = {},
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
-
optionalImportsMap = {}) {
|
|
57
|
-
return (0, load_1.load)(text, {
|
|
58
|
-
secretsMap,
|
|
59
|
-
optionalImportsMap,
|
|
60
|
-
optionalImportEntrypoints: import_constants_js_1.optionalImportEntrypoints,
|
|
61
|
-
importMap,
|
|
62
|
-
});
|
|
63
|
-
}
|
package/dist/load/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type OptionalImportMap, type SecretMap } from "./import_type.js";
|
|
2
|
-
import * as importMap from "./import_map.js";
|
|
3
|
-
import { optionalImportEntrypoints } from "./import_constants.js";
|
|
4
|
-
export { optionalImportEntrypoints, importMap, type OptionalImportMap, type SecretMap, };
|
|
5
|
-
/**
|
|
6
|
-
* Load a LangChain module from a serialized text representation.
|
|
7
|
-
* NOTE: This functionality is currently in beta.
|
|
8
|
-
* Loaded classes may change independently of semver.
|
|
9
|
-
* @param text Serialized text representation of the module.
|
|
10
|
-
* @param secretsMap
|
|
11
|
-
* @param optionalImportsMap
|
|
12
|
-
* @returns A loaded instance of a LangChain module.
|
|
13
|
-
*/
|
|
14
|
-
export declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>): Promise<T>;
|
package/dist/load/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { load as coreLoad } from "@langchain/core/load";
|
|
2
|
-
import * as importMap from "./import_map.js";
|
|
3
|
-
import { optionalImportEntrypoints } from "./import_constants.js";
|
|
4
|
-
export { optionalImportEntrypoints, importMap, };
|
|
5
|
-
/**
|
|
6
|
-
* Load a LangChain module from a serialized text representation.
|
|
7
|
-
* NOTE: This functionality is currently in beta.
|
|
8
|
-
* Loaded classes may change independently of semver.
|
|
9
|
-
* @param text Serialized text representation of the module.
|
|
10
|
-
* @param secretsMap
|
|
11
|
-
* @param optionalImportsMap
|
|
12
|
-
* @returns A loaded instance of a LangChain module.
|
|
13
|
-
*/
|
|
14
|
-
export async function load(text,
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
secretsMap = {},
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
optionalImportsMap = {}) {
|
|
19
|
-
return coreLoad(text, {
|
|
20
|
-
secretsMap,
|
|
21
|
-
optionalImportsMap,
|
|
22
|
-
optionalImportEntrypoints,
|
|
23
|
-
importMap,
|
|
24
|
-
});
|
|
25
|
-
}
|
package/dist/load/map_keys.cjs
DELETED
package/dist/load/map_keys.d.ts
DELETED
package/dist/load/map_keys.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("@langchain/core/load/serializable"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@langchain/core/load/serializable";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@langchain/core/load/serializable";
|
package/dist/output_parsers.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseLLMOutputParser } from "@langchain/core/output_parsers";
|
|
2
|
-
import { JsonOutputKeyToolsParserParamsInterop } from "@langchain/core/output_parsers/openai_tools";
|
|
3
|
-
import { ChatGeneration } from "@langchain/core/outputs";
|
|
4
|
-
import { ToolCall } from "@langchain/core/messages/tool";
|
|
5
|
-
import { InteropZodType } from "@langchain/core/utils/types";
|
|
6
|
-
interface AnthropicToolsOutputParserParams<T extends Record<string, any>> extends JsonOutputKeyToolsParserParamsInterop<T> {
|
|
7
|
-
}
|
|
8
|
-
export declare class AnthropicToolsOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseLLMOutputParser<T> {
|
|
9
|
-
static lc_name(): string;
|
|
10
|
-
lc_namespace: string[];
|
|
11
|
-
returnId: boolean;
|
|
12
|
-
/** The type of tool calls to return. */
|
|
13
|
-
keyName: string;
|
|
14
|
-
/** Whether to return only the first tool call. */
|
|
15
|
-
returnSingle: boolean;
|
|
16
|
-
zodSchema?: InteropZodType<T>;
|
|
17
|
-
constructor(params: AnthropicToolsOutputParserParams<T>);
|
|
18
|
-
protected _validateResult(result: unknown): Promise<T>;
|
|
19
|
-
parseResult(generations: ChatGeneration[]): Promise<T>;
|
|
20
|
-
}
|
|
21
|
-
export declare function extractToolCalls(content: Record<string, any>[]): ToolCall[];
|
|
22
|
-
export {};
|
package/dist/types.cjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAnthropicImageBlockParam = isAnthropicImageBlockParam;
|
|
4
|
-
function isAnthropicImageBlockParam(block) {
|
|
5
|
-
if (block == null) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (typeof block !== "object") {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (!("type" in block) || block.type !== "image") {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (!("source" in block) || typeof block.source !== "object") {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
if (block.source == null) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
if (!("type" in block.source)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (block.source.type === "base64") {
|
|
24
|
-
if (!("media_type" in block.source)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (typeof block.source.media_type !== "string") {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (!("data" in block.source)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (typeof block.source.data !== "string") {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
if (block.source.type === "url") {
|
|
39
|
-
if (!("url" in block.source)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (typeof block.source.url !== "string") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export function isAnthropicImageBlockParam(block) {
|
|
2
|
-
if (block == null) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (typeof block !== "object") {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (!("type" in block) || block.type !== "image") {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (!("source" in block) || typeof block.source !== "object") {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (block.source == null) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
if (!("type" in block.source)) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
if (block.source.type === "base64") {
|
|
21
|
-
if (!("media_type" in block.source)) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (typeof block.source.media_type !== "string") {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (!("data" in block.source)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (typeof block.source.data !== "string") {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
if (block.source.type === "url") {
|
|
36
|
-
if (!("url" in block.source)) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
if (typeof block.source.url !== "string") {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
package/dist/utils/errors.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export type LangChainErrorCodes = "INVALID_PROMPT_INPUT" | "INVALID_TOOL_RESULTS" | "MESSAGE_COERCION_FAILURE" | "MODEL_AUTHENTICATION" | "MODEL_NOT_FOUND" | "MODEL_RATE_LIMIT" | "OUTPUT_PARSING_FAILURE";
|
|
2
|
-
export declare function addLangChainErrorFields(error: any, lc_error_code: LangChainErrorCodes): any;
|
|
3
|
-
export declare function wrapAnthropicClientError(e: any): any;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This util file contains functions for converting LangChain messages to Anthropic messages.
|
|
3
|
-
*/
|
|
4
|
-
import { type BaseMessage } from "@langchain/core/messages";
|
|
5
|
-
import { ToolCall } from "@langchain/core/messages/tool";
|
|
6
|
-
import { AnthropicMessageCreateParams, AnthropicToolResponse } from "../types.js";
|
|
7
|
-
export declare function _convertLangChainToolCallToAnthropic(toolCall: ToolCall): AnthropicToolResponse;
|
|
8
|
-
/**
|
|
9
|
-
* Formats messages as a prompt for the model.
|
|
10
|
-
* Used in LangSmith, export is important here.
|
|
11
|
-
* @param messages The base messages to format as a prompt.
|
|
12
|
-
* @returns The formatted prompt.
|
|
13
|
-
*/
|
|
14
|
-
export declare function _convertMessagesToAnthropicPayload(messages: BaseMessage[]): AnthropicMessageCreateParams;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This util file contains functions for converting Anthropic messages to LangChain messages.
|
|
3
|
-
*/
|
|
4
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
5
|
-
import { AIMessageChunk } from "@langchain/core/messages";
|
|
6
|
-
import { ChatGeneration } from "@langchain/core/outputs";
|
|
7
|
-
import { AnthropicMessageResponse } from "../types.js";
|
|
8
|
-
export declare function _makeMessageChunkFromAnthropicEvent(data: Anthropic.Messages.RawMessageStreamEvent, fields: {
|
|
9
|
-
streamUsage: boolean;
|
|
10
|
-
coerceContentToString: boolean;
|
|
11
|
-
}): {
|
|
12
|
-
chunk: AIMessageChunk;
|
|
13
|
-
} | null;
|
|
14
|
-
export declare function anthropicResponseToChatMessages(messages: AnthropicMessageResponse[], additionalKwargs: Record<string, unknown>): ChatGeneration[];
|
package/dist/utils/tools.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { Anthropic } from "@anthropic-ai/sdk";
|
|
2
|
-
import { AnthropicToolChoice } from "../types.js";
|
|
3
|
-
export declare function handleToolChoice(toolChoice?: AnthropicToolChoice): Anthropic.Messages.ToolChoiceAuto | Anthropic.Messages.ToolChoiceAny | Anthropic.Messages.ToolChoiceTool | undefined;
|
package/experimental.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/experimental/index.cjs');
|
package/experimental.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/experimental/index.js'
|
package/experimental.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/experimental/index.js'
|
package/experimental.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/experimental/index.js'
|
package/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/index.cjs');
|
package/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/index.js'
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/index.js'
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/index.js'
|