@langchain/core 1.3.1 → 1.3.2
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 +6 -0
- package/dist/language_models/base.cjs +1 -1
- package/dist/language_models/base.js +1 -1
- package/dist/messages/index.cjs +5 -0
- package/dist/messages/index.cjs.map +1 -1
- package/dist/messages/index.d.cts +2 -1
- package/dist/messages/index.d.ts +2 -1
- package/dist/messages/index.js +4 -1
- package/dist/messages/index.js.map +1 -1
- package/dist/messages/notification.cjs +69 -0
- package/dist/messages/notification.cjs.map +1 -0
- package/dist/messages/notification.d.cts +54 -0
- package/dist/messages/notification.d.cts.map +1 -0
- package/dist/messages/notification.d.ts +54 -0
- package/dist/messages/notification.d.ts.map +1 -0
- package/dist/messages/notification.js +68 -0
- package/dist/messages/notification.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @langchain/core
|
|
2
2
|
|
|
3
|
+
## 1.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#12051](https://github.com/langchain-ai/langchainjs/pull/12051) [`71fd01a`](https://github.com/langchain-ai/langchainjs/commit/71fd01ab6edb530a3d52cebcfc191674c10138d2) Thanks [@thushanth-bengre-langchain](https://github.com/thushanth-bengre-langchain)! - feat(core): add `addNotificationMetadata`, `getNotificationMetadata` and the `NotificationMetadata` type for marking messages the agent harness adds.
|
|
8
|
+
|
|
3
9
|
## 1.3.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -139,7 +139,7 @@ var BaseLangChain = class extends require_base.Runnable {
|
|
|
139
139
|
this.callbacks = params.callbacks;
|
|
140
140
|
this.tags = params.tags ?? [];
|
|
141
141
|
this.metadata = params.metadata ?? {};
|
|
142
|
-
this._addVersion("@langchain/core", "1.3.
|
|
142
|
+
this._addVersion("@langchain/core", "1.3.2");
|
|
143
143
|
}
|
|
144
144
|
_addVersion(pkg, version) {
|
|
145
145
|
const existing = this.metadata?.versions;
|
|
@@ -138,7 +138,7 @@ var BaseLangChain = class extends Runnable {
|
|
|
138
138
|
this.callbacks = params.callbacks;
|
|
139
139
|
this.tags = params.tags ?? [];
|
|
140
140
|
this.metadata = params.metadata ?? {};
|
|
141
|
-
this._addVersion("@langchain/core", "1.3.
|
|
141
|
+
this._addVersion("@langchain/core", "1.3.2");
|
|
142
142
|
}
|
|
143
143
|
_addVersion(pkg, version) {
|
|
144
144
|
const existing = this.metadata?.versions;
|
package/dist/messages/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ const require_modifier = require("./modifier.cjs");
|
|
|
13
13
|
const require_system = require("./system.cjs");
|
|
14
14
|
const require_utils = require("./utils.cjs");
|
|
15
15
|
const require_transformers = require("./transformers.cjs");
|
|
16
|
+
const require_notification = require("./notification.cjs");
|
|
16
17
|
const require_index = require("./content/index.cjs");
|
|
17
18
|
//#region src/messages/index.ts
|
|
18
19
|
var messages_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
@@ -38,6 +39,7 @@ var messages_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
38
39
|
_mergeLists: () => require_base._mergeLists,
|
|
39
40
|
_mergeObj: () => require_base._mergeObj,
|
|
40
41
|
_mergeStatus: () => require_base._mergeStatus,
|
|
42
|
+
addNotificationMetadata: () => require_notification.addNotificationMetadata,
|
|
41
43
|
coerceMessageLikeToMessage: () => require_utils.coerceMessageLikeToMessage,
|
|
42
44
|
collapseToolCallChunks: () => require_utils.collapseToolCallChunks,
|
|
43
45
|
convertToChunk: () => require_utils.convertToChunk,
|
|
@@ -47,6 +49,7 @@ var messages_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
47
49
|
defaultToolCallParser: () => require_messages_tool.defaultToolCallParser,
|
|
48
50
|
filterMessages: () => require_transformers.filterMessages,
|
|
49
51
|
getBufferString: () => require_utils.getBufferString,
|
|
52
|
+
getNotificationMetadata: () => require_notification.getNotificationMetadata,
|
|
50
53
|
iife: () => require_utils.iife,
|
|
51
54
|
isAIMessage: () => require_ai.isAIMessage,
|
|
52
55
|
isAIMessageChunk: () => require_ai.isAIMessageChunk,
|
|
@@ -104,6 +107,7 @@ exports._mergeDicts = require_base._mergeDicts;
|
|
|
104
107
|
exports._mergeLists = require_base._mergeLists;
|
|
105
108
|
exports._mergeObj = require_base._mergeObj;
|
|
106
109
|
exports._mergeStatus = require_base._mergeStatus;
|
|
110
|
+
exports.addNotificationMetadata = require_notification.addNotificationMetadata;
|
|
107
111
|
exports.coerceMessageLikeToMessage = require_utils.coerceMessageLikeToMessage;
|
|
108
112
|
exports.collapseToolCallChunks = require_utils.collapseToolCallChunks;
|
|
109
113
|
exports.convertToChunk = require_utils.convertToChunk;
|
|
@@ -113,6 +117,7 @@ exports.defaultTextSplitter = require_transformers.defaultTextSplitter;
|
|
|
113
117
|
exports.defaultToolCallParser = require_messages_tool.defaultToolCallParser;
|
|
114
118
|
exports.filterMessages = require_transformers.filterMessages;
|
|
115
119
|
exports.getBufferString = require_utils.getBufferString;
|
|
120
|
+
exports.getNotificationMetadata = require_notification.getNotificationMetadata;
|
|
116
121
|
exports.iife = require_utils.iife;
|
|
117
122
|
exports.isAIMessage = require_ai.isAIMessage;
|
|
118
123
|
exports.isAIMessageChunk = require_ai.isAIMessageChunk;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/messages/index.ts"],"sourcesContent":["export * from \"./ai.js\";\nexport * from \"./base.js\";\nexport * from \"./chat.js\";\nexport * from \"./function.js\";\nexport * from \"./human.js\";\nexport * from \"./system.js\";\nexport * from \"./utils.js\";\nexport * from \"./transformers.js\";\nexport * from \"./metadata.js\";\nexport * from \"./message.js\";\nexport * from \"./modifier.js\";\nexport * from \"./tool.js\";\n\n// This is an old export for backwards compatibility with existing multimodal content blocks\n// TODO: remove this in v2\nexport * from \"./content/data.js\";\nexport * from \"./content/index.js\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/messages/index.ts"],"sourcesContent":["export * from \"./ai.js\";\nexport * from \"./base.js\";\nexport * from \"./chat.js\";\nexport * from \"./function.js\";\nexport * from \"./human.js\";\nexport * from \"./system.js\";\nexport * from \"./utils.js\";\nexport * from \"./transformers.js\";\nexport * from \"./metadata.js\";\nexport * from \"./message.js\";\nexport * from \"./modifier.js\";\nexport * from \"./notification.js\";\nexport * from \"./tool.js\";\n\n// This is an old export for backwards compatibility with existing multimodal content blocks\n// TODO: remove this in v2\nexport * from \"./content/data.js\";\nexport * from \"./content/index.js\";\n"],"mappings":""}
|
|
@@ -12,4 +12,5 @@ import { $Expand, $MergeDiscriminatedUnion, $MergeObjects, Constructor, RawInput
|
|
|
12
12
|
import { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage } from "./message.cjs";
|
|
13
13
|
import { RemoveMessage, RemoveMessageFields } from "./modifier.cjs";
|
|
14
14
|
import { FilterMessagesFields, MessageChunkUnion, MessageTypeOrClass, MessageUnion, TrimMessagesFields, defaultTextSplitter, filterMessages, mergeMessageRuns, trimMessages } from "./transformers.cjs";
|
|
15
|
-
|
|
15
|
+
import { NotificationMetadata, addNotificationMetadata, getNotificationMetadata } from "./notification.cjs";
|
|
16
|
+
export { $Expand, $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeDiscriminatedUnion, $MergeMessageStructure, $MergeObjects, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, AIMessage, AIMessageChunk, AIMessageChunkFields, AIMessageFields, BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, ChatMessage, ChatMessageChunk, ChatMessageFields, Constructor, ContentBlock, DEFAULT_MERGE_IGNORE_KEYS, Data, DirectToolOutput, FilterMessagesFields, FunctionCall, FunctionMessage, FunctionMessageChunk, FunctionMessageFields, HumanMessage, HumanMessageChunk, HumanMessageFields, ImageDetail, InputTokenDetails, InvalidToolCall, KNOWN_BLOCK_TYPES, MergeDictsOptions, Message, MessageChunkUnion, MessageContent, MessageContentComplex, MessageContentImageUrl, MessageContentText, MessageFieldWithRole, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, MessageTypeOrClass, MessageUnion, ModalitiesTokenDetails, NotificationMetadata, OpenAIToolCall, OutputTokenDetails, PartialContentBlock, ProviderFormatTypes, RawInputToolCallChunk, RemoveMessage, RemoveMessageFields, ResponseMetadata, StandardContentBlockConverter, StandardMessageStructure, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, SystemMessage, SystemMessageChunk, SystemMessageFields, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, TrimMessagesFields, UsageMetadata, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, addNotificationMetadata, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, getNotificationMetadata, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, parseBase64DataUrl, parseMimeType, trimMessages };
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ import { $Expand, $MergeDiscriminatedUnion, $MergeObjects, Constructor, RawInput
|
|
|
12
12
|
import { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage } from "./message.js";
|
|
13
13
|
import { RemoveMessage, RemoveMessageFields } from "./modifier.js";
|
|
14
14
|
import { FilterMessagesFields, MessageChunkUnion, MessageTypeOrClass, MessageUnion, TrimMessagesFields, defaultTextSplitter, filterMessages, mergeMessageRuns, trimMessages } from "./transformers.js";
|
|
15
|
-
|
|
15
|
+
import { NotificationMetadata, addNotificationMetadata, getNotificationMetadata } from "./notification.js";
|
|
16
|
+
export { $Expand, $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeDiscriminatedUnion, $MergeMessageStructure, $MergeObjects, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, AIMessage, AIMessageChunk, AIMessageChunkFields, AIMessageFields, BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, ChatMessage, ChatMessageChunk, ChatMessageFields, Constructor, ContentBlock, DEFAULT_MERGE_IGNORE_KEYS, Data, DirectToolOutput, FilterMessagesFields, FunctionCall, FunctionMessage, FunctionMessageChunk, FunctionMessageFields, HumanMessage, HumanMessageChunk, HumanMessageFields, ImageDetail, InputTokenDetails, InvalidToolCall, KNOWN_BLOCK_TYPES, MergeDictsOptions, Message, MessageChunkUnion, MessageContent, MessageContentComplex, MessageContentImageUrl, MessageContentText, MessageFieldWithRole, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, MessageTypeOrClass, MessageUnion, ModalitiesTokenDetails, NotificationMetadata, OpenAIToolCall, OutputTokenDetails, PartialContentBlock, ProviderFormatTypes, RawInputToolCallChunk, RemoveMessage, RemoveMessageFields, ResponseMetadata, StandardContentBlockConverter, StandardMessageStructure, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, SystemMessage, SystemMessageChunk, SystemMessageFields, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, TrimMessagesFields, UsageMetadata, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, addNotificationMetadata, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, getNotificationMetadata, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, parseBase64DataUrl, parseMimeType, trimMessages };
|
package/dist/messages/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { RemoveMessage } from "./modifier.js";
|
|
|
12
12
|
import { SystemMessage, SystemMessageChunk, isSystemMessage, isSystemMessageChunk } from "./system.js";
|
|
13
13
|
import { coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, getBufferString, iife, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages } from "./utils.js";
|
|
14
14
|
import { defaultTextSplitter, filterMessages, mergeMessageRuns, trimMessages } from "./transformers.js";
|
|
15
|
+
import { addNotificationMetadata, getNotificationMetadata } from "./notification.js";
|
|
15
16
|
import { KNOWN_BLOCK_TYPES } from "./content/index.js";
|
|
16
17
|
//#region src/messages/index.ts
|
|
17
18
|
var messages_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -37,6 +38,7 @@ var messages_exports = /* @__PURE__ */ __exportAll({
|
|
|
37
38
|
_mergeLists: () => _mergeLists,
|
|
38
39
|
_mergeObj: () => _mergeObj,
|
|
39
40
|
_mergeStatus: () => _mergeStatus,
|
|
41
|
+
addNotificationMetadata: () => addNotificationMetadata,
|
|
40
42
|
coerceMessageLikeToMessage: () => coerceMessageLikeToMessage,
|
|
41
43
|
collapseToolCallChunks: () => collapseToolCallChunks,
|
|
42
44
|
convertToChunk: () => convertToChunk,
|
|
@@ -46,6 +48,7 @@ var messages_exports = /* @__PURE__ */ __exportAll({
|
|
|
46
48
|
defaultToolCallParser: () => defaultToolCallParser,
|
|
47
49
|
filterMessages: () => filterMessages,
|
|
48
50
|
getBufferString: () => getBufferString,
|
|
51
|
+
getNotificationMetadata: () => getNotificationMetadata,
|
|
49
52
|
iife: () => iife,
|
|
50
53
|
isAIMessage: () => isAIMessage,
|
|
51
54
|
isAIMessageChunk: () => isAIMessageChunk,
|
|
@@ -81,6 +84,6 @@ var messages_exports = /* @__PURE__ */ __exportAll({
|
|
|
81
84
|
trimMessages: () => trimMessages
|
|
82
85
|
});
|
|
83
86
|
//#endregion
|
|
84
|
-
export { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ChatMessage, ChatMessageChunk, DEFAULT_MERGE_IGNORE_KEYS, FunctionMessage, FunctionMessageChunk, HumanMessage, HumanMessageChunk, KNOWN_BLOCK_TYPES, RemoveMessage, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, messages_exports, parseBase64DataUrl, parseMimeType, trimMessages };
|
|
87
|
+
export { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ChatMessage, ChatMessageChunk, DEFAULT_MERGE_IGNORE_KEYS, FunctionMessage, FunctionMessageChunk, HumanMessage, HumanMessageChunk, KNOWN_BLOCK_TYPES, RemoveMessage, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, addNotificationMetadata, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, getNotificationMetadata, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, messages_exports, parseBase64DataUrl, parseMimeType, trimMessages };
|
|
85
88
|
|
|
86
89
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/messages/index.ts"],"sourcesContent":["export * from \"./ai.js\";\nexport * from \"./base.js\";\nexport * from \"./chat.js\";\nexport * from \"./function.js\";\nexport * from \"./human.js\";\nexport * from \"./system.js\";\nexport * from \"./utils.js\";\nexport * from \"./transformers.js\";\nexport * from \"./metadata.js\";\nexport * from \"./message.js\";\nexport * from \"./modifier.js\";\nexport * from \"./tool.js\";\n\n// This is an old export for backwards compatibility with existing multimodal content blocks\n// TODO: remove this in v2\nexport * from \"./content/data.js\";\nexport * from \"./content/index.js\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/messages/index.ts"],"sourcesContent":["export * from \"./ai.js\";\nexport * from \"./base.js\";\nexport * from \"./chat.js\";\nexport * from \"./function.js\";\nexport * from \"./human.js\";\nexport * from \"./system.js\";\nexport * from \"./utils.js\";\nexport * from \"./transformers.js\";\nexport * from \"./metadata.js\";\nexport * from \"./message.js\";\nexport * from \"./modifier.js\";\nexport * from \"./notification.js\";\nexport * from \"./tool.js\";\n\n// This is an old export for backwards compatibility with existing multimodal content blocks\n// TODO: remove this in v2\nexport * from \"./content/data.js\";\nexport * from \"./content/index.js\";\n"],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const require_human = require("./human.cjs");
|
|
2
|
+
//#region src/messages/notification.ts
|
|
3
|
+
/**
|
|
4
|
+
* Return a copy of `message` marked as added by the agent harness.
|
|
5
|
+
*
|
|
6
|
+
* Use it for a human message the user didn't type, such as a background task
|
|
7
|
+
* update or a conversation summary. It sets `additional_kwargs.lc_source`
|
|
8
|
+
* and, when `data` is given, `additional_kwargs.lc_data`. Any earlier
|
|
9
|
+
* `lc_source` and `lc_data` are removed first. LangChain's chat model
|
|
10
|
+
* integrations don't send these keys to the model.
|
|
11
|
+
*
|
|
12
|
+
* It doesn't change the content. Write the content the model reads yourself.
|
|
13
|
+
*
|
|
14
|
+
* Anyone who can send input to a thread can set these keys. Don't use them to
|
|
15
|
+
* decide whether to trust a message.
|
|
16
|
+
*
|
|
17
|
+
* `mergeMessageRuns` and chunk `concat` join a notification with adjacent
|
|
18
|
+
* human messages; the merged message keeps the metadata and concatenates
|
|
19
|
+
* `lc_source`.
|
|
20
|
+
*
|
|
21
|
+
* @param message - The message to mark.
|
|
22
|
+
* @param metadata - The feature that added the message and its fields. `data` must be JSON-serializable.
|
|
23
|
+
* @returns A shallow copy of `message`, with the same `id`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { HumanMessage, addNotificationMetadata } from "@langchain/core/messages";
|
|
28
|
+
*
|
|
29
|
+
* const message = addNotificationMetadata(
|
|
30
|
+
* new HumanMessage("Background task t_42 finished."),
|
|
31
|
+
* { source: "async_subagent", data: { task_id: "t_42", status: "success" } }
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function addNotificationMetadata(message, metadata) {
|
|
36
|
+
const { lc_data: _, ...kwargs } = message.additional_kwargs ?? {};
|
|
37
|
+
const additional_kwargs = {
|
|
38
|
+
...kwargs,
|
|
39
|
+
lc_source: metadata.source
|
|
40
|
+
};
|
|
41
|
+
if (metadata.data !== void 0) additional_kwargs.lc_data = { ...metadata.data };
|
|
42
|
+
const { lc_kwargs: _kwargs, lc_serializable: _serializable, lc_namespace: _namespace, type: _type, ...fields } = message;
|
|
43
|
+
return new require_human.HumanMessage({
|
|
44
|
+
...fields,
|
|
45
|
+
additional_kwargs
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Return the notification metadata of `message`.
|
|
50
|
+
*
|
|
51
|
+
* @param message - The message to read.
|
|
52
|
+
* @returns The metadata `addNotificationMetadata` set, or `undefined` for a
|
|
53
|
+
* message without a string `lc_source`. `data` is a copy of `lc_data`, left out
|
|
54
|
+
* unless `lc_data` is an object.
|
|
55
|
+
*/
|
|
56
|
+
function getNotificationMetadata(message) {
|
|
57
|
+
const source = message.additional_kwargs?.lc_source;
|
|
58
|
+
if (typeof source !== "string") return void 0;
|
|
59
|
+
const data = message.additional_kwargs?.lc_data;
|
|
60
|
+
return typeof data === "object" && data !== null && !Array.isArray(data) ? {
|
|
61
|
+
source,
|
|
62
|
+
data: { ...data }
|
|
63
|
+
} : { source };
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.addNotificationMetadata = addNotificationMetadata;
|
|
67
|
+
exports.getNotificationMetadata = getNotificationMetadata;
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=notification.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.cjs","names":["HumanMessage"],"sources":["../../src/messages/notification.ts"],"sourcesContent":["import type { BaseMessage } from \"./base.js\";\nimport { HumanMessage } from \"./human.js\";\n\n/** Which feature added a message, and that feature's fields. */\nexport interface NotificationMetadata {\n /** The feature that added the message, e.g. `\"async_subagent\"`. */\n source: string;\n /** The feature's fields, documented by that feature. */\n data?: Record<string, unknown>;\n}\n\n/**\n * Return a copy of `message` marked as added by the agent harness.\n *\n * Use it for a human message the user didn't type, such as a background task\n * update or a conversation summary. It sets `additional_kwargs.lc_source`\n * and, when `data` is given, `additional_kwargs.lc_data`. Any earlier\n * `lc_source` and `lc_data` are removed first. LangChain's chat model\n * integrations don't send these keys to the model.\n *\n * It doesn't change the content. Write the content the model reads yourself.\n *\n * Anyone who can send input to a thread can set these keys. Don't use them to\n * decide whether to trust a message.\n *\n * `mergeMessageRuns` and chunk `concat` join a notification with adjacent\n * human messages; the merged message keeps the metadata and concatenates\n * `lc_source`.\n *\n * @param message - The message to mark.\n * @param metadata - The feature that added the message and its fields. `data` must be JSON-serializable.\n * @returns A shallow copy of `message`, with the same `id`.\n *\n * @example\n * ```typescript\n * import { HumanMessage, addNotificationMetadata } from \"@langchain/core/messages\";\n *\n * const message = addNotificationMetadata(\n * new HumanMessage(\"Background task t_42 finished.\"),\n * { source: \"async_subagent\", data: { task_id: \"t_42\", status: \"success\" } }\n * );\n * ```\n */\nexport function addNotificationMetadata(\n message: HumanMessage,\n metadata: NotificationMetadata\n): HumanMessage {\n const { lc_data: _, ...kwargs } = message.additional_kwargs ?? {};\n const additional_kwargs: Record<string, unknown> = {\n ...kwargs,\n lc_source: metadata.source,\n };\n if (metadata.data !== undefined) {\n additional_kwargs.lc_data = { ...metadata.data };\n }\n const {\n lc_kwargs: _kwargs,\n lc_serializable: _serializable,\n lc_namespace: _namespace,\n type: _type,\n ...fields\n } = message;\n return new HumanMessage({ ...fields, additional_kwargs });\n}\n\n/**\n * Return the notification metadata of `message`.\n *\n * @param message - The message to read.\n * @returns The metadata `addNotificationMetadata` set, or `undefined` for a\n * message without a string `lc_source`. `data` is a copy of `lc_data`, left out\n * unless `lc_data` is an object.\n */\nexport function getNotificationMetadata(\n message: BaseMessage\n): NotificationMetadata | undefined {\n const source = message.additional_kwargs?.lc_source;\n if (typeof source !== \"string\") return undefined;\n const data = message.additional_kwargs?.lc_data;\n const isRecord =\n typeof data === \"object\" && data !== null && !Array.isArray(data);\n return isRecord\n ? { source, data: { ...(data as Record<string, unknown>) } }\n : { source };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,wBACd,SACA,UACc;CACd,MAAM,EAAE,SAAS,GAAG,GAAG,WAAW,QAAQ,qBAAqB,CAAC;CAChE,MAAM,oBAA6C;EACjD,GAAG;EACH,WAAW,SAAS;CACtB;CACA,IAAI,SAAS,SAAS,KAAA,GACpB,kBAAkB,UAAU,EAAE,GAAG,SAAS,KAAK;CAEjD,MAAM,EACJ,WAAW,SACX,iBAAiB,eACjB,cAAc,YACd,MAAM,OACN,GAAG,WACD;CACJ,OAAO,IAAIA,cAAAA,aAAa;EAAE,GAAG;EAAQ;CAAkB,CAAC;AAC1D;;;;;;;;;AAUA,SAAgB,wBACd,SACkC;CAClC,MAAM,SAAS,QAAQ,mBAAmB;CAC1C,IAAI,OAAO,WAAW,UAAU,OAAO,KAAA;CACvC,MAAM,OAAO,QAAQ,mBAAmB;CAGxC,OADE,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,IAAI,IAE9D;EAAE;EAAQ,MAAM,EAAE,GAAI,KAAiC;CAAE,IACzD,EAAE,OAAO;AACf"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseMessage } from "./base.cjs";
|
|
2
|
+
import { HumanMessage } from "./human.cjs";
|
|
3
|
+
//#region src/messages/notification.d.ts
|
|
4
|
+
/** Which feature added a message, and that feature's fields. */
|
|
5
|
+
export interface NotificationMetadata {
|
|
6
|
+
/** The feature that added the message, e.g. `"async_subagent"`. */
|
|
7
|
+
source: string;
|
|
8
|
+
/** The feature's fields, documented by that feature. */
|
|
9
|
+
data?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return a copy of `message` marked as added by the agent harness.
|
|
13
|
+
*
|
|
14
|
+
* Use it for a human message the user didn't type, such as a background task
|
|
15
|
+
* update or a conversation summary. It sets `additional_kwargs.lc_source`
|
|
16
|
+
* and, when `data` is given, `additional_kwargs.lc_data`. Any earlier
|
|
17
|
+
* `lc_source` and `lc_data` are removed first. LangChain's chat model
|
|
18
|
+
* integrations don't send these keys to the model.
|
|
19
|
+
*
|
|
20
|
+
* It doesn't change the content. Write the content the model reads yourself.
|
|
21
|
+
*
|
|
22
|
+
* Anyone who can send input to a thread can set these keys. Don't use them to
|
|
23
|
+
* decide whether to trust a message.
|
|
24
|
+
*
|
|
25
|
+
* `mergeMessageRuns` and chunk `concat` join a notification with adjacent
|
|
26
|
+
* human messages; the merged message keeps the metadata and concatenates
|
|
27
|
+
* `lc_source`.
|
|
28
|
+
*
|
|
29
|
+
* @param message - The message to mark.
|
|
30
|
+
* @param metadata - The feature that added the message and its fields. `data` must be JSON-serializable.
|
|
31
|
+
* @returns A shallow copy of `message`, with the same `id`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import { HumanMessage, addNotificationMetadata } from "@langchain/core/messages";
|
|
36
|
+
*
|
|
37
|
+
* const message = addNotificationMetadata(
|
|
38
|
+
* new HumanMessage("Background task t_42 finished."),
|
|
39
|
+
* { source: "async_subagent", data: { task_id: "t_42", status: "success" } }
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function addNotificationMetadata(message: HumanMessage, metadata: NotificationMetadata): HumanMessage;
|
|
44
|
+
/**
|
|
45
|
+
* Return the notification metadata of `message`.
|
|
46
|
+
*
|
|
47
|
+
* @param message - The message to read.
|
|
48
|
+
* @returns The metadata `addNotificationMetadata` set, or `undefined` for a
|
|
49
|
+
* message without a string `lc_source`. `data` is a copy of `lc_data`, left out
|
|
50
|
+
* unless `lc_data` is an object.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getNotificationMetadata(message: BaseMessage): NotificationMetadata | undefined;
|
|
53
|
+
//#endregion
|
|
54
|
+
//# sourceMappingURL=notification.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.d.cts","names":[],"sources":["../../src/messages/notification.ts"],"mappings":";;;;iBAIiB;;EAEf;;EAEA,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCO,wBACd,SAAS,cACT,UAAU,uBACT;;;;;;;;;wBA2Ba,wBACd,SAAS,cACR"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseMessage } from "./base.js";
|
|
2
|
+
import { HumanMessage } from "./human.js";
|
|
3
|
+
//#region src/messages/notification.d.ts
|
|
4
|
+
/** Which feature added a message, and that feature's fields. */
|
|
5
|
+
export interface NotificationMetadata {
|
|
6
|
+
/** The feature that added the message, e.g. `"async_subagent"`. */
|
|
7
|
+
source: string;
|
|
8
|
+
/** The feature's fields, documented by that feature. */
|
|
9
|
+
data?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return a copy of `message` marked as added by the agent harness.
|
|
13
|
+
*
|
|
14
|
+
* Use it for a human message the user didn't type, such as a background task
|
|
15
|
+
* update or a conversation summary. It sets `additional_kwargs.lc_source`
|
|
16
|
+
* and, when `data` is given, `additional_kwargs.lc_data`. Any earlier
|
|
17
|
+
* `lc_source` and `lc_data` are removed first. LangChain's chat model
|
|
18
|
+
* integrations don't send these keys to the model.
|
|
19
|
+
*
|
|
20
|
+
* It doesn't change the content. Write the content the model reads yourself.
|
|
21
|
+
*
|
|
22
|
+
* Anyone who can send input to a thread can set these keys. Don't use them to
|
|
23
|
+
* decide whether to trust a message.
|
|
24
|
+
*
|
|
25
|
+
* `mergeMessageRuns` and chunk `concat` join a notification with adjacent
|
|
26
|
+
* human messages; the merged message keeps the metadata and concatenates
|
|
27
|
+
* `lc_source`.
|
|
28
|
+
*
|
|
29
|
+
* @param message - The message to mark.
|
|
30
|
+
* @param metadata - The feature that added the message and its fields. `data` must be JSON-serializable.
|
|
31
|
+
* @returns A shallow copy of `message`, with the same `id`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import { HumanMessage, addNotificationMetadata } from "@langchain/core/messages";
|
|
36
|
+
*
|
|
37
|
+
* const message = addNotificationMetadata(
|
|
38
|
+
* new HumanMessage("Background task t_42 finished."),
|
|
39
|
+
* { source: "async_subagent", data: { task_id: "t_42", status: "success" } }
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function addNotificationMetadata(message: HumanMessage, metadata: NotificationMetadata): HumanMessage;
|
|
44
|
+
/**
|
|
45
|
+
* Return the notification metadata of `message`.
|
|
46
|
+
*
|
|
47
|
+
* @param message - The message to read.
|
|
48
|
+
* @returns The metadata `addNotificationMetadata` set, or `undefined` for a
|
|
49
|
+
* message without a string `lc_source`. `data` is a copy of `lc_data`, left out
|
|
50
|
+
* unless `lc_data` is an object.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getNotificationMetadata(message: BaseMessage): NotificationMetadata | undefined;
|
|
53
|
+
//#endregion
|
|
54
|
+
//# sourceMappingURL=notification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.d.ts","names":[],"sources":["../../src/messages/notification.ts"],"mappings":";;;;iBAIiB;;EAEf;;EAEA,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCO,wBACd,SAAS,cACT,UAAU,uBACT;;;;;;;;;wBA2Ba,wBACd,SAAS,cACR"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HumanMessage } from "./human.js";
|
|
2
|
+
//#region src/messages/notification.ts
|
|
3
|
+
/**
|
|
4
|
+
* Return a copy of `message` marked as added by the agent harness.
|
|
5
|
+
*
|
|
6
|
+
* Use it for a human message the user didn't type, such as a background task
|
|
7
|
+
* update or a conversation summary. It sets `additional_kwargs.lc_source`
|
|
8
|
+
* and, when `data` is given, `additional_kwargs.lc_data`. Any earlier
|
|
9
|
+
* `lc_source` and `lc_data` are removed first. LangChain's chat model
|
|
10
|
+
* integrations don't send these keys to the model.
|
|
11
|
+
*
|
|
12
|
+
* It doesn't change the content. Write the content the model reads yourself.
|
|
13
|
+
*
|
|
14
|
+
* Anyone who can send input to a thread can set these keys. Don't use them to
|
|
15
|
+
* decide whether to trust a message.
|
|
16
|
+
*
|
|
17
|
+
* `mergeMessageRuns` and chunk `concat` join a notification with adjacent
|
|
18
|
+
* human messages; the merged message keeps the metadata and concatenates
|
|
19
|
+
* `lc_source`.
|
|
20
|
+
*
|
|
21
|
+
* @param message - The message to mark.
|
|
22
|
+
* @param metadata - The feature that added the message and its fields. `data` must be JSON-serializable.
|
|
23
|
+
* @returns A shallow copy of `message`, with the same `id`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { HumanMessage, addNotificationMetadata } from "@langchain/core/messages";
|
|
28
|
+
*
|
|
29
|
+
* const message = addNotificationMetadata(
|
|
30
|
+
* new HumanMessage("Background task t_42 finished."),
|
|
31
|
+
* { source: "async_subagent", data: { task_id: "t_42", status: "success" } }
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function addNotificationMetadata(message, metadata) {
|
|
36
|
+
const { lc_data: _, ...kwargs } = message.additional_kwargs ?? {};
|
|
37
|
+
const additional_kwargs = {
|
|
38
|
+
...kwargs,
|
|
39
|
+
lc_source: metadata.source
|
|
40
|
+
};
|
|
41
|
+
if (metadata.data !== void 0) additional_kwargs.lc_data = { ...metadata.data };
|
|
42
|
+
const { lc_kwargs: _kwargs, lc_serializable: _serializable, lc_namespace: _namespace, type: _type, ...fields } = message;
|
|
43
|
+
return new HumanMessage({
|
|
44
|
+
...fields,
|
|
45
|
+
additional_kwargs
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Return the notification metadata of `message`.
|
|
50
|
+
*
|
|
51
|
+
* @param message - The message to read.
|
|
52
|
+
* @returns The metadata `addNotificationMetadata` set, or `undefined` for a
|
|
53
|
+
* message without a string `lc_source`. `data` is a copy of `lc_data`, left out
|
|
54
|
+
* unless `lc_data` is an object.
|
|
55
|
+
*/
|
|
56
|
+
function getNotificationMetadata(message) {
|
|
57
|
+
const source = message.additional_kwargs?.lc_source;
|
|
58
|
+
if (typeof source !== "string") return void 0;
|
|
59
|
+
const data = message.additional_kwargs?.lc_data;
|
|
60
|
+
return typeof data === "object" && data !== null && !Array.isArray(data) ? {
|
|
61
|
+
source,
|
|
62
|
+
data: { ...data }
|
|
63
|
+
} : { source };
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { addNotificationMetadata, getNotificationMetadata };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.js","names":[],"sources":["../../src/messages/notification.ts"],"sourcesContent":["import type { BaseMessage } from \"./base.js\";\nimport { HumanMessage } from \"./human.js\";\n\n/** Which feature added a message, and that feature's fields. */\nexport interface NotificationMetadata {\n /** The feature that added the message, e.g. `\"async_subagent\"`. */\n source: string;\n /** The feature's fields, documented by that feature. */\n data?: Record<string, unknown>;\n}\n\n/**\n * Return a copy of `message` marked as added by the agent harness.\n *\n * Use it for a human message the user didn't type, such as a background task\n * update or a conversation summary. It sets `additional_kwargs.lc_source`\n * and, when `data` is given, `additional_kwargs.lc_data`. Any earlier\n * `lc_source` and `lc_data` are removed first. LangChain's chat model\n * integrations don't send these keys to the model.\n *\n * It doesn't change the content. Write the content the model reads yourself.\n *\n * Anyone who can send input to a thread can set these keys. Don't use them to\n * decide whether to trust a message.\n *\n * `mergeMessageRuns` and chunk `concat` join a notification with adjacent\n * human messages; the merged message keeps the metadata and concatenates\n * `lc_source`.\n *\n * @param message - The message to mark.\n * @param metadata - The feature that added the message and its fields. `data` must be JSON-serializable.\n * @returns A shallow copy of `message`, with the same `id`.\n *\n * @example\n * ```typescript\n * import { HumanMessage, addNotificationMetadata } from \"@langchain/core/messages\";\n *\n * const message = addNotificationMetadata(\n * new HumanMessage(\"Background task t_42 finished.\"),\n * { source: \"async_subagent\", data: { task_id: \"t_42\", status: \"success\" } }\n * );\n * ```\n */\nexport function addNotificationMetadata(\n message: HumanMessage,\n metadata: NotificationMetadata\n): HumanMessage {\n const { lc_data: _, ...kwargs } = message.additional_kwargs ?? {};\n const additional_kwargs: Record<string, unknown> = {\n ...kwargs,\n lc_source: metadata.source,\n };\n if (metadata.data !== undefined) {\n additional_kwargs.lc_data = { ...metadata.data };\n }\n const {\n lc_kwargs: _kwargs,\n lc_serializable: _serializable,\n lc_namespace: _namespace,\n type: _type,\n ...fields\n } = message;\n return new HumanMessage({ ...fields, additional_kwargs });\n}\n\n/**\n * Return the notification metadata of `message`.\n *\n * @param message - The message to read.\n * @returns The metadata `addNotificationMetadata` set, or `undefined` for a\n * message without a string `lc_source`. `data` is a copy of `lc_data`, left out\n * unless `lc_data` is an object.\n */\nexport function getNotificationMetadata(\n message: BaseMessage\n): NotificationMetadata | undefined {\n const source = message.additional_kwargs?.lc_source;\n if (typeof source !== \"string\") return undefined;\n const data = message.additional_kwargs?.lc_data;\n const isRecord =\n typeof data === \"object\" && data !== null && !Array.isArray(data);\n return isRecord\n ? { source, data: { ...(data as Record<string, unknown>) } }\n : { source };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,wBACd,SACA,UACc;CACd,MAAM,EAAE,SAAS,GAAG,GAAG,WAAW,QAAQ,qBAAqB,CAAC;CAChE,MAAM,oBAA6C;EACjD,GAAG;EACH,WAAW,SAAS;CACtB;CACA,IAAI,SAAS,SAAS,KAAA,GACpB,kBAAkB,UAAU,EAAE,GAAG,SAAS,KAAK;CAEjD,MAAM,EACJ,WAAW,SACX,iBAAiB,eACjB,cAAc,YACd,MAAM,OACN,GAAG,WACD;CACJ,OAAO,IAAI,aAAa;EAAE,GAAG;EAAQ;CAAkB,CAAC;AAC1D;;;;;;;;;AAUA,SAAgB,wBACd,SACkC;CAClC,MAAM,SAAS,QAAQ,mBAAmB;CAC1C,IAAI,OAAO,WAAW,UAAU,OAAO,KAAA;CACvC,MAAM,OAAO,QAAQ,mBAAmB;CAGxC,OADE,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,IAAI,IAE9D;EAAE;EAAQ,MAAM,EAAE,GAAI,KAAiC;CAAE,IACzD,EAAE,OAAO;AACf"}
|