@langchain/core 1.0.2 → 1.0.4
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 +12 -0
- package/dist/agents.d.ts.map +1 -1
- package/dist/errors/index.cjs +1 -1
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/language_models/base.cjs +60 -9
- package/dist/language_models/base.cjs.map +1 -1
- package/dist/language_models/base.d.cts +11 -0
- package/dist/language_models/base.d.cts.map +1 -1
- package/dist/language_models/base.d.ts +11 -0
- package/dist/language_models/base.d.ts.map +1 -1
- package/dist/language_models/base.js +60 -9
- package/dist/language_models/base.js.map +1 -1
- package/dist/load/import_map.cjs +3 -1
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +3 -1
- package/dist/load/import_map.js.map +1 -1
- package/dist/tools/index.cjs +17 -4
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +13 -4
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts +13 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.d.cts +94 -2
- package/dist/tools/types.d.cts.map +1 -1
- package/dist/tools/types.d.ts +94 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/utils/async_caller.cjs +10 -4
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.d.cts.map +1 -1
- package/dist/utils/async_caller.d.ts.map +1 -1
- package/dist/utils/async_caller.js +10 -4
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/format.cjs +12 -0
- package/dist/utils/format.cjs.map +1 -0
- package/dist/utils/format.d.cts +58 -0
- package/dist/utils/format.d.cts.map +1 -0
- package/dist/utils/format.d.ts +58 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +6 -0
- package/dist/utils/format.js.map +1 -0
- package/package.json +12 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/utils/format.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A function that converts data from one format to another.
|
|
4
|
+
*
|
|
5
|
+
* This is commonly used for transforming message content blocks between different
|
|
6
|
+
* provider-specific formats and standardized internal representations.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The input type to convert from
|
|
9
|
+
* @template U - The output type to convert to
|
|
10
|
+
*
|
|
11
|
+
* @param input - The data to convert
|
|
12
|
+
* @returns The converted data in the target format
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Convert from OpenAI format to standard format
|
|
17
|
+
* const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {
|
|
18
|
+
* return { type: "text", text: block.text };
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
type Converter<T, U> = (input: T) => U;
|
|
23
|
+
/**
|
|
24
|
+
* A pair of bidirectional conversion functions for transforming data between two formats.
|
|
25
|
+
*
|
|
26
|
+
* This type is used throughout the message system to enable conversion between
|
|
27
|
+
* provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and
|
|
28
|
+
* standardized internal content block representations. The `encode` function
|
|
29
|
+
* typically converts from a standard format to a provider-specific format, while
|
|
30
|
+
* `decode` converts from a provider-specific format back to the standard format.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The first format (typically the standard/internal format)
|
|
33
|
+
* @template U - The second format (typically the provider-specific format)
|
|
34
|
+
*
|
|
35
|
+
* @property encode - Converts from format T to format U
|
|
36
|
+
* @property decode - Converts from format U back to format T
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Converter pair for OpenAI message blocks
|
|
41
|
+
* const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {
|
|
42
|
+
* encode: (standard) => ({ text: standard.text }),
|
|
43
|
+
* decode: (openai) => ({ type: "text", text: openai.text })
|
|
44
|
+
* };
|
|
45
|
+
*
|
|
46
|
+
* // Usage
|
|
47
|
+
* const standardBlock = { type: "text", text: "Hello" };
|
|
48
|
+
* const openaiBlock = openAIConverter.encode(standardBlock);
|
|
49
|
+
* const backToStandard = openAIConverter.decode(openaiBlock);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
type ConverterPair<T, U> = {
|
|
53
|
+
encode: Converter<T, U>;
|
|
54
|
+
decode: Converter<U, T>;
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { Converter, ConverterPair };
|
|
58
|
+
//# sourceMappingURL=format.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.cts","names":["Converter","T","U","ConverterPair"],"sources":["../../src/utils/format.d.ts"],"sourcesContent":["/**\n * A function that converts data from one format to another.\n *\n * This is commonly used for transforming message content blocks between different\n * provider-specific formats and standardized internal representations.\n *\n * @template T - The input type to convert from\n * @template U - The output type to convert to\n *\n * @param input - The data to convert\n * @returns The converted data in the target format\n *\n * @example\n * ```typescript\n * // Convert from OpenAI format to standard format\n * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {\n * return { type: \"text\", text: block.text };\n * };\n * ```\n */\nexport type Converter<T, U> = (input: T) => U;\n/**\n * A pair of bidirectional conversion functions for transforming data between two formats.\n *\n * This type is used throughout the message system to enable conversion between\n * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and\n * standardized internal content block representations. The `encode` function\n * typically converts from a standard format to a provider-specific format, while\n * `decode` converts from a provider-specific format back to the standard format.\n *\n * @template T - The first format (typically the standard/internal format)\n * @template U - The second format (typically the provider-specific format)\n *\n * @property encode - Converts from format T to format U\n * @property decode - Converts from format U back to format T\n *\n * @example\n * ```typescript\n * // Converter pair for OpenAI message blocks\n * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {\n * encode: (standard) => ({ text: standard.text }),\n * decode: (openai) => ({ type: \"text\", text: openai.text })\n * };\n *\n * // Usage\n * const standardBlock = { type: \"text\", text: \"Hello\" };\n * const openaiBlock = openAIConverter.encode(standardBlock);\n * const backToStandard = openAIConverter.decode(openaiBlock);\n * ```\n */\nexport type ConverterPair<T, U> = {\n encode: Converter<T, U>;\n decode: Converter<U, T>;\n};\n"],"mappings":";;AAoBA;;;;AAA6C;AA8B7C;;;;;;;;AAEqB;;;;;;KAhCTA,0BAA0BC,MAAMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BhCC;UACAH,UAAUC,GAAGC;UACbF,UAAUE,GAAGD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/utils/format.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A function that converts data from one format to another.
|
|
4
|
+
*
|
|
5
|
+
* This is commonly used for transforming message content blocks between different
|
|
6
|
+
* provider-specific formats and standardized internal representations.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The input type to convert from
|
|
9
|
+
* @template U - The output type to convert to
|
|
10
|
+
*
|
|
11
|
+
* @param input - The data to convert
|
|
12
|
+
* @returns The converted data in the target format
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Convert from OpenAI format to standard format
|
|
17
|
+
* const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {
|
|
18
|
+
* return { type: "text", text: block.text };
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
type Converter<T, U> = (input: T) => U;
|
|
23
|
+
/**
|
|
24
|
+
* A pair of bidirectional conversion functions for transforming data between two formats.
|
|
25
|
+
*
|
|
26
|
+
* This type is used throughout the message system to enable conversion between
|
|
27
|
+
* provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and
|
|
28
|
+
* standardized internal content block representations. The `encode` function
|
|
29
|
+
* typically converts from a standard format to a provider-specific format, while
|
|
30
|
+
* `decode` converts from a provider-specific format back to the standard format.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The first format (typically the standard/internal format)
|
|
33
|
+
* @template U - The second format (typically the provider-specific format)
|
|
34
|
+
*
|
|
35
|
+
* @property encode - Converts from format T to format U
|
|
36
|
+
* @property decode - Converts from format U back to format T
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Converter pair for OpenAI message blocks
|
|
41
|
+
* const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {
|
|
42
|
+
* encode: (standard) => ({ text: standard.text }),
|
|
43
|
+
* decode: (openai) => ({ type: "text", text: openai.text })
|
|
44
|
+
* };
|
|
45
|
+
*
|
|
46
|
+
* // Usage
|
|
47
|
+
* const standardBlock = { type: "text", text: "Hello" };
|
|
48
|
+
* const openaiBlock = openAIConverter.encode(standardBlock);
|
|
49
|
+
* const backToStandard = openAIConverter.decode(openaiBlock);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
type ConverterPair<T, U> = {
|
|
53
|
+
encode: Converter<T, U>;
|
|
54
|
+
decode: Converter<U, T>;
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { Converter, ConverterPair };
|
|
58
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","names":["Converter","T","U","ConverterPair"],"sources":["../../src/utils/format.d.ts"],"sourcesContent":["/**\n * A function that converts data from one format to another.\n *\n * This is commonly used for transforming message content blocks between different\n * provider-specific formats and standardized internal representations.\n *\n * @template T - The input type to convert from\n * @template U - The output type to convert to\n *\n * @param input - The data to convert\n * @returns The converted data in the target format\n *\n * @example\n * ```typescript\n * // Convert from OpenAI format to standard format\n * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {\n * return { type: \"text\", text: block.text };\n * };\n * ```\n */\nexport type Converter<T, U> = (input: T) => U;\n/**\n * A pair of bidirectional conversion functions for transforming data between two formats.\n *\n * This type is used throughout the message system to enable conversion between\n * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and\n * standardized internal content block representations. The `encode` function\n * typically converts from a standard format to a provider-specific format, while\n * `decode` converts from a provider-specific format back to the standard format.\n *\n * @template T - The first format (typically the standard/internal format)\n * @template U - The second format (typically the provider-specific format)\n *\n * @property encode - Converts from format T to format U\n * @property decode - Converts from format U back to format T\n *\n * @example\n * ```typescript\n * // Converter pair for OpenAI message blocks\n * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {\n * encode: (standard) => ({ text: standard.text }),\n * decode: (openai) => ({ type: \"text\", text: openai.text })\n * };\n *\n * // Usage\n * const standardBlock = { type: \"text\", text: \"Hello\" };\n * const openaiBlock = openAIConverter.encode(standardBlock);\n * const backToStandard = openAIConverter.decode(openaiBlock);\n * ```\n */\nexport type ConverterPair<T, U> = {\n encode: Converter<T, U>;\n decode: Converter<U, T>;\n};\n"],"mappings":";;AAoBA;;;;AAA6C;AA8B7C;;;;;;;;AAEqB;;;;;;KAhCTA,0BAA0BC,MAAMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BhCC;UACAH,UAAUC,GAAGC;UACbF,UAAUE,GAAGD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","names":[],"sources":["../../src/utils/format.ts"],"sourcesContent":["/**\n * A function that converts data from one format to another.\n *\n * This is commonly used for transforming message content blocks between different\n * provider-specific formats and standardized internal representations.\n *\n * @template T - The input type to convert from\n * @template U - The output type to convert to\n *\n * @param input - The data to convert\n * @returns The converted data in the target format\n *\n * @example\n * ```typescript\n * // Convert from OpenAI format to standard format\n * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {\n * return { type: \"text\", text: block.text };\n * };\n * ```\n */\nexport type Converter<T, U> = (input: T) => U;\n\n/**\n * A pair of bidirectional conversion functions for transforming data between two formats.\n *\n * This type is used throughout the message system to enable conversion between\n * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and\n * standardized internal content block representations. The `encode` function\n * typically converts from a standard format to a provider-specific format, while\n * `decode` converts from a provider-specific format back to the standard format.\n *\n * @template T - The first format (typically the standard/internal format)\n * @template U - The second format (typically the provider-specific format)\n *\n * @property encode - Converts from format T to format U\n * @property decode - Converts from format U back to format T\n *\n * @example\n * ```typescript\n * // Converter pair for OpenAI message blocks\n * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {\n * encode: (standard) => ({ text: standard.text }),\n * decode: (openai) => ({ type: \"text\", text: openai.text })\n * };\n *\n * // Usage\n * const standardBlock = { type: \"text\", text: \"Hello\" };\n * const openaiBlock = openAIConverter.encode(standardBlock);\n * const backToStandard = openAIConverter.decode(openaiBlock);\n * ```\n */\nexport type ConverterPair<T, U> = {\n encode: Converter<T, U>;\n decode: Converter<U, T>;\n};\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Core LangChain.js abstractions and schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -589,6 +589,17 @@
|
|
|
589
589
|
"default": "./dist/utils/event_source_parse.js"
|
|
590
590
|
}
|
|
591
591
|
},
|
|
592
|
+
"./utils/format": {
|
|
593
|
+
"input": "./src/utils/format.ts",
|
|
594
|
+
"require": {
|
|
595
|
+
"types": "./dist/utils/format.d.cts",
|
|
596
|
+
"default": "./dist/utils/format.cjs"
|
|
597
|
+
},
|
|
598
|
+
"import": {
|
|
599
|
+
"types": "./dist/utils/format.d.ts",
|
|
600
|
+
"default": "./dist/utils/format.js"
|
|
601
|
+
}
|
|
602
|
+
},
|
|
592
603
|
"./utils/function_calling": {
|
|
593
604
|
"input": "./src/utils/function_calling.ts",
|
|
594
605
|
"require": {
|