@langchain/core 1.1.7 → 1.1.8
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 +8 -0
- package/dist/caches/index.d.cts.map +1 -1
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/load/index.cjs +85 -25
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.d.cts +113 -3
- package/dist/load/index.d.cts.map +1 -1
- package/dist/load/index.d.ts +113 -3
- package/dist/load/index.d.ts.map +1 -1
- package/dist/load/index.js +85 -25
- package/dist/load/index.js.map +1 -1
- package/dist/load/serializable.cjs +6 -1
- package/dist/load/serializable.cjs.map +1 -1
- package/dist/load/serializable.d.cts +15 -1
- package/dist/load/serializable.d.cts.map +1 -1
- package/dist/load/serializable.d.ts +15 -1
- package/dist/load/serializable.d.ts.map +1 -1
- package/dist/load/serializable.js +6 -1
- package/dist/load/serializable.js.map +1 -1
- package/dist/load/validation.cjs +98 -0
- package/dist/load/validation.cjs.map +1 -0
- package/dist/load/validation.js +95 -0
- package/dist/load/validation.js.map +1 -0
- package/dist/messages/base.cjs +1 -0
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +2 -3
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +2 -3
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +1 -0
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/message.cjs.map +1 -1
- package/dist/messages/message.d.cts +34 -1
- package/dist/messages/message.d.cts.map +1 -1
- package/dist/messages/message.d.ts +34 -1
- package/dist/messages/message.d.ts.map +1 -1
- package/dist/messages/message.js.map +1 -1
- package/dist/messages/tool.d.ts.map +1 -1
- package/dist/utils/event_source_parse.d.cts.map +1 -1
- package/dist/utils/stream.d.cts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializable.js","names":["obj: T","root: SerializedFields","secretsMap: { [key: string]: string }","current: any","serializableClass: typeof Serializable","kwargs?: SerializedFields","aliases: { [key: string]: string }","secrets: { [key: string]: string }","read: any","write: any"],"sources":["../../src/load/serializable.ts"],"sourcesContent":["import { type SerializedFields, keyToJson, mapKeys } from \"./map_keys.js\";\n\nexport interface BaseSerialized<T extends string> {\n lc: number;\n type: T;\n id: string[];\n name?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n graph?: Record<string, any>;\n}\n\nexport interface SerializedConstructor extends BaseSerialized<\"constructor\"> {\n kwargs: SerializedFields;\n}\n\nexport interface SerializedSecret extends BaseSerialized<\"secret\"> {}\n\nexport interface SerializedNotImplemented\n extends BaseSerialized<\"not_implemented\"> {}\n\nexport type Serialized =\n | SerializedConstructor\n | SerializedSecret\n | SerializedNotImplemented;\n\nfunction shallowCopy<T extends object>(obj: T): T {\n return Array.isArray(obj) ? ([...obj] as T) : ({ ...obj } as T);\n}\n\nfunction replaceSecrets(\n root: SerializedFields,\n secretsMap: { [key: string]: string }\n): SerializedFields {\n const result = shallowCopy(root);\n for (const [path, secretId] of Object.entries(secretsMap)) {\n const [last, ...partsReverse] = path.split(\".\").reverse();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let current: any = result;\n for (const part of partsReverse.reverse()) {\n if (current[part] === undefined) {\n break;\n }\n current[part] = shallowCopy(current[part]);\n current = current[part];\n }\n if (current[last] !== undefined) {\n current[last] = {\n lc: 1,\n type: \"secret\",\n id: [secretId],\n };\n }\n }\n return result;\n}\n\n/**\n * Get a unique name for the module, rather than parent class implementations.\n * Should not be subclassed, subclass lc_name above instead.\n */\nexport function get_lc_unique_name(\n serializableClass: typeof Serializable\n): string {\n // \"super\" here would refer to the parent class of Serializable,\n // when we want the parent class of the module actually calling this method.\n const parentClass = Object.getPrototypeOf(serializableClass);\n const lcNameIsSubclassed =\n typeof serializableClass.lc_name === \"function\" &&\n (typeof parentClass.lc_name !== \"function\" ||\n serializableClass.lc_name() !== parentClass.lc_name());\n if (lcNameIsSubclassed) {\n return serializableClass.lc_name();\n } else {\n return serializableClass.name;\n }\n}\n\nexport interface SerializableInterface {\n get lc_id(): string[];\n}\n\nexport abstract class Serializable implements SerializableInterface {\n lc_serializable = false;\n\n lc_kwargs: SerializedFields;\n\n /**\n * A path to the module that contains the class, eg. [\"langchain\", \"llms\"]\n * Usually should be the same as the entrypoint the class is exported from.\n */\n abstract lc_namespace: string[];\n\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string {\n return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof Serializable),\n ];\n }\n\n /**\n * A map of secrets, which will be omitted from serialization.\n * Keys are paths to the secret in constructor args, e.g. \"foo.bar.baz\".\n * Values are the secret ids, which will be used when deserializing.\n */\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n /**\n * A map of additional attributes to merge with constructor args.\n * Keys are the attribute names, e.g. \"foo\".\n * Values are the attribute values, which will be serialized.\n * These attributes need to be accepted by the constructor as arguments.\n */\n get lc_attributes(): SerializedFields | undefined {\n return undefined;\n }\n\n /**\n * A map of aliases for constructor args.\n * Keys are the attribute names, e.g. \"foo\".\n * Values are the alias that will replace the key in serialization.\n * This is used to eg. make argument names match Python.\n */\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n /**\n * A manual list of keys that should be serialized.\n * If not overridden, all fields passed into the constructor will be serialized.\n */\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\n constructor(kwargs?: SerializedFields, ..._args: never[]) {\n if (this.lc_serializable_keys !== undefined) {\n this.lc_kwargs = Object.fromEntries(\n Object.entries(kwargs || {}).filter(([key]) =>\n this.lc_serializable_keys?.includes(key)\n )\n );\n } else {\n this.lc_kwargs = kwargs ?? {};\n }\n }\n\n toJSON(): Serialized {\n if (!this.lc_serializable) {\n return this.toJSONNotImplemented();\n }\n if (\n // eslint-disable-next-line no-instanceof/no-instanceof\n this.lc_kwargs instanceof Serializable ||\n typeof this.lc_kwargs !== \"object\" ||\n Array.isArray(this.lc_kwargs)\n ) {\n // We do not support serialization of classes with arg not a POJO\n // I'm aware the check above isn't as strict as it could be\n return this.toJSONNotImplemented();\n }\n\n const aliases: { [key: string]: string } = {};\n const secrets: { [key: string]: string } = {};\n const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {\n acc[key] = key in this ? this[key as keyof this] : this.lc_kwargs[key];\n return acc;\n }, {} as SerializedFields);\n // get secrets, attributes and aliases from all superclasses\n for (\n let current = Object.getPrototypeOf(this);\n current;\n current = Object.getPrototypeOf(current)\n ) {\n Object.assign(aliases, Reflect.get(current, \"lc_aliases\", this));\n Object.assign(secrets, Reflect.get(current, \"lc_secrets\", this));\n Object.assign(kwargs, Reflect.get(current, \"lc_attributes\", this));\n }\n\n // include all secrets used, even if not in kwargs,\n // will be replaced with sentinel value in replaceSecrets\n Object.keys(secrets).forEach((keyPath) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let read: any = this;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let write: any = kwargs;\n\n const [last, ...partsReverse] = keyPath.split(\".\").reverse();\n for (const key of partsReverse.reverse()) {\n if (!(key in read) || read[key] === undefined) return;\n if (!(key in write) || write[key] === undefined) {\n if (typeof read[key] === \"object\" && read[key] != null) {\n write[key] = {};\n } else if (Array.isArray(read[key])) {\n write[key] = [];\n }\n }\n\n read = read[key];\n write = write[key];\n }\n\n if (last in read && read[last] !== undefined) {\n write[last] = write[last] || read[last];\n }\n });\n\n return {\n lc: 1,\n type: \"constructor\",\n id: this.lc_id,\n kwargs: mapKeys(\n Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs,\n keyToJson,\n aliases\n ),\n };\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n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AU,MAAM,SAAS,QACpC;SAAI,OAAO,KAAK,SAAS,YAAY,KAAK,QAAQ,MAChD,MAAM,OAAO,CAAE;cACN,MAAM,QAAQ,KAAK,KAAK,EACjC,MAAM,OAAO,CAAE;IAChB;IAGH,OAAO,KAAK;IACZ,QAAQ,MAAM;GACf;AAED,OAAI,QAAQ,QAAQ,KAAK,UAAU,QACjC,MAAM,QAAQ,MAAM,SAAS,KAAK;EAErC,EAAC;AAEF,SAAO;GACL,IAAI;GACJ,MAAM;GACN,IAAI,KAAK;GACT,QAAQ,QACN,OAAO,KAAK,QAAQ,CAAC,SAAS,eAAe,QAAQ,QAAQ,GAAG,QAChE,WACA,QACD;EACF;CACF;CAED,uBAAiD;AAC/C,SAAO;GACL,IAAI;GACJ,MAAM;GACN,IAAI,KAAK;EACV;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"serializable.js","names":["obj: T","root: SerializedFields","secretsMap: { [key: string]: string }","current: any","serializableClass: typeof Serializable","kwargs?: SerializedFields","aliases: { [key: string]: string }","secrets: { [key: string]: string }","read: any","write: any","escapedKwargs: SerializedFields"],"sources":["../../src/load/serializable.ts"],"sourcesContent":["import { type SerializedFields, keyToJson, mapKeys } from \"./map_keys.js\";\nimport { escapeIfNeeded } from \"./validation.js\";\n\nexport interface BaseSerialized<T extends string> {\n lc: number;\n type: T;\n id: string[];\n name?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n graph?: Record<string, any>;\n}\n\nexport interface SerializedConstructor extends BaseSerialized<\"constructor\"> {\n kwargs: SerializedFields;\n}\n\nexport interface SerializedSecret extends BaseSerialized<\"secret\"> {}\n\nexport interface SerializedNotImplemented\n extends BaseSerialized<\"not_implemented\"> {}\n\nexport type Serialized =\n | SerializedConstructor\n | SerializedSecret\n | SerializedNotImplemented;\n\nfunction shallowCopy<T extends object>(obj: T): T {\n return Array.isArray(obj) ? ([...obj] as T) : ({ ...obj } as T);\n}\n\nfunction replaceSecrets(\n root: SerializedFields,\n secretsMap: { [key: string]: string }\n): SerializedFields {\n const result = shallowCopy(root);\n for (const [path, secretId] of Object.entries(secretsMap)) {\n const [last, ...partsReverse] = path.split(\".\").reverse();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let current: any = result;\n for (const part of partsReverse.reverse()) {\n if (current[part] === undefined) {\n break;\n }\n current[part] = shallowCopy(current[part]);\n current = current[part];\n }\n if (current[last] !== undefined) {\n current[last] = {\n lc: 1,\n type: \"secret\",\n id: [secretId],\n };\n }\n }\n return result;\n}\n\n/**\n * Get a unique name for the module, rather than parent class implementations.\n * Should not be subclassed, subclass lc_name above instead.\n */\nexport function get_lc_unique_name(\n serializableClass: typeof Serializable\n): string {\n // \"super\" here would refer to the parent class of Serializable,\n // when we want the parent class of the module actually calling this method.\n const parentClass = Object.getPrototypeOf(serializableClass);\n const lcNameIsSubclassed =\n typeof serializableClass.lc_name === \"function\" &&\n (typeof parentClass.lc_name !== \"function\" ||\n serializableClass.lc_name() !== parentClass.lc_name());\n if (lcNameIsSubclassed) {\n return serializableClass.lc_name();\n } else {\n return serializableClass.name;\n }\n}\n\n/**\n * Interface for objects that can be serialized.\n * This is a duck-typed interface to avoid circular imports.\n */\nexport interface SerializableLike {\n lc_serializable: boolean;\n lc_secrets?: Record<string, string>;\n toJSON(): {\n lc: number;\n type: string;\n id: string[];\n kwargs?: Record<string, unknown>;\n };\n}\n\nexport interface SerializableInterface {\n get lc_id(): string[];\n}\n\nexport abstract class Serializable implements SerializableInterface {\n lc_serializable = false;\n\n lc_kwargs: SerializedFields;\n\n /**\n * A path to the module that contains the class, eg. [\"langchain\", \"llms\"]\n * Usually should be the same as the entrypoint the class is exported from.\n */\n abstract lc_namespace: string[];\n\n /**\n * The name of the serializable. Override to provide an alias or\n * to preserve the serialized module name in minified environments.\n *\n * Implemented as a static method to support loading logic.\n */\n static lc_name(): string {\n return this.name;\n }\n\n /**\n * The final serialized identifier for the module.\n */\n get lc_id(): string[] {\n return [\n ...this.lc_namespace,\n get_lc_unique_name(this.constructor as typeof Serializable),\n ];\n }\n\n /**\n * A map of secrets, which will be omitted from serialization.\n * Keys are paths to the secret in constructor args, e.g. \"foo.bar.baz\".\n * Values are the secret ids, which will be used when deserializing.\n */\n get lc_secrets(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n /**\n * A map of additional attributes to merge with constructor args.\n * Keys are the attribute names, e.g. \"foo\".\n * Values are the attribute values, which will be serialized.\n * These attributes need to be accepted by the constructor as arguments.\n */\n get lc_attributes(): SerializedFields | undefined {\n return undefined;\n }\n\n /**\n * A map of aliases for constructor args.\n * Keys are the attribute names, e.g. \"foo\".\n * Values are the alias that will replace the key in serialization.\n * This is used to eg. make argument names match Python.\n */\n get lc_aliases(): { [key: string]: string } | undefined {\n return undefined;\n }\n\n /**\n * A manual list of keys that should be serialized.\n * If not overridden, all fields passed into the constructor will be serialized.\n */\n get lc_serializable_keys(): string[] | undefined {\n return undefined;\n }\n\n constructor(kwargs?: SerializedFields, ..._args: never[]) {\n if (this.lc_serializable_keys !== undefined) {\n this.lc_kwargs = Object.fromEntries(\n Object.entries(kwargs || {}).filter(([key]) =>\n this.lc_serializable_keys?.includes(key)\n )\n );\n } else {\n this.lc_kwargs = kwargs ?? {};\n }\n }\n\n toJSON(): Serialized {\n if (!this.lc_serializable) {\n return this.toJSONNotImplemented();\n }\n if (\n // eslint-disable-next-line no-instanceof/no-instanceof\n this.lc_kwargs instanceof Serializable ||\n typeof this.lc_kwargs !== \"object\" ||\n Array.isArray(this.lc_kwargs)\n ) {\n // We do not support serialization of classes with arg not a POJO\n // I'm aware the check above isn't as strict as it could be\n return this.toJSONNotImplemented();\n }\n\n const aliases: { [key: string]: string } = {};\n const secrets: { [key: string]: string } = {};\n const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {\n acc[key] = key in this ? this[key as keyof this] : this.lc_kwargs[key];\n return acc;\n }, {} as SerializedFields);\n // get secrets, attributes and aliases from all superclasses\n for (\n let current = Object.getPrototypeOf(this);\n current;\n current = Object.getPrototypeOf(current)\n ) {\n Object.assign(aliases, Reflect.get(current, \"lc_aliases\", this));\n Object.assign(secrets, Reflect.get(current, \"lc_secrets\", this));\n Object.assign(kwargs, Reflect.get(current, \"lc_attributes\", this));\n }\n\n // include all secrets used, even if not in kwargs,\n // will be replaced with sentinel value in replaceSecrets\n Object.keys(secrets).forEach((keyPath) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let read: any = this;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let write: any = kwargs;\n\n const [last, ...partsReverse] = keyPath.split(\".\").reverse();\n for (const key of partsReverse.reverse()) {\n if (!(key in read) || read[key] === undefined) return;\n if (!(key in write) || write[key] === undefined) {\n if (typeof read[key] === \"object\" && read[key] != null) {\n write[key] = {};\n } else if (Array.isArray(read[key])) {\n write[key] = [];\n }\n }\n\n read = read[key];\n write = write[key];\n }\n\n if (last in read && read[last] !== undefined) {\n write[last] = write[last] || read[last];\n }\n });\n\n const escapedKwargs: SerializedFields = {};\n for (const [key, value] of Object.entries(kwargs)) {\n escapedKwargs[key] = escapeIfNeeded(value);\n }\n\n // Now add secret markers - these are added AFTER escaping so they won't be escaped\n const kwargsWithSecrets = Object.keys(secrets).length\n ? replaceSecrets(escapedKwargs, secrets)\n : escapedKwargs;\n\n // Finally transform keys to JSON format\n const processedKwargs = mapKeys(kwargsWithSecrets, keyToJson, aliases);\n\n return {\n lc: 1,\n type: \"constructor\",\n id: this.lc_id,\n kwargs: processedKwargs,\n };\n }\n\n toJSONNotImplemented(): SerializedNotImplemented {\n return {\n lc: 1,\n type: \"not_implemented\",\n id: this.lc_id,\n };\n }\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,YAA8BA,KAAW;AAChD,QAAO,MAAM,QAAQ,IAAI,GAAI,CAAC,GAAG,GAAI,IAAU,EAAE,GAAG,IAAK;AAC1D;AAED,SAAS,eACPC,MACAC,YACkB;CAClB,MAAM,SAAS,YAAY,KAAK;AAChC,MAAK,MAAM,CAAC,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C,EAAC;EAEF,MAAMC,gBAAkC,CAAE;AAC1C,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,OAAO,EAC/C,cAAc,OAAO,eAAe,MAAM;EAI5C,MAAM,oBAAoB,OAAO,KAAK,QAAQ,CAAC,SAC3C,eAAe,eAAe,QAAQ,GACtC;EAGJ,MAAM,kBAAkB,QAAQ,mBAAmB,WAAW,QAAQ;AAEtE,SAAO;GACL,IAAI;GACJ,MAAM;GACN,IAAI,KAAK;GACT,QAAQ;EACT;CACF;CAED,uBAAiD;AAC/C,SAAO;GACL,IAAI;GACJ,MAAM;GACN,IAAI,KAAK;EACV;CACF;AACF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/load/validation.ts
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel key used to mark escaped user objects during serialization.
|
|
5
|
+
*
|
|
6
|
+
* When a plain object contains 'lc' key (which could be confused with LC objects),
|
|
7
|
+
* we wrap it as `{"__lc_escaped__": {...original...}}`.
|
|
8
|
+
*/
|
|
9
|
+
const LC_ESCAPED_KEY = "__lc_escaped__";
|
|
10
|
+
/**
|
|
11
|
+
* Check if an object needs escaping to prevent confusion with LC objects.
|
|
12
|
+
*
|
|
13
|
+
* An object needs escaping if:
|
|
14
|
+
* 1. It has an `'lc'` key (could be confused with LC serialization format)
|
|
15
|
+
* 2. It has only the escape key (would be mistaken for an escaped object)
|
|
16
|
+
*/
|
|
17
|
+
function needsEscaping(obj) {
|
|
18
|
+
return "lc" in obj || Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Wrap an object in the escape marker.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* {"key": "value"} // becomes {"__lc_escaped__": {"key": "value"}}
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function escapeObject(obj) {
|
|
29
|
+
return { [LC_ESCAPED_KEY]: obj };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if an object is an escaped user object.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* {"__lc_escaped__": {...}} // is an escaped object
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function isEscapedObject(obj) {
|
|
40
|
+
return Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if an object looks like a Serializable instance (duck typing).
|
|
44
|
+
*/
|
|
45
|
+
function isSerializableLike(obj) {
|
|
46
|
+
return obj !== null && typeof obj === "object" && "lc_serializable" in obj && typeof obj.toJSON === "function";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Escape a value if it needs escaping (contains `lc` key).
|
|
50
|
+
*
|
|
51
|
+
* This is a simpler version of `serializeValue` that doesn't handle Serializable
|
|
52
|
+
* objects - it's meant to be called on kwargs values that have already been
|
|
53
|
+
* processed by `toJSON()`.
|
|
54
|
+
*
|
|
55
|
+
* @param value - The value to potentially escape.
|
|
56
|
+
* @returns The value with any `lc`-containing objects wrapped in escape markers.
|
|
57
|
+
*/
|
|
58
|
+
function escapeIfNeeded(value) {
|
|
59
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
60
|
+
if (isSerializableLike(value)) return value;
|
|
61
|
+
const record = value;
|
|
62
|
+
if (needsEscaping(record)) return escapeObject(record);
|
|
63
|
+
const result = {};
|
|
64
|
+
for (const [key, val] of Object.entries(record)) result[key] = escapeIfNeeded(val);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(value)) return value.map((item) => escapeIfNeeded(item));
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Unescape a value, processing escape markers in object values and arrays.
|
|
72
|
+
*
|
|
73
|
+
* When an escaped object is encountered (`{"__lc_escaped__": ...}`), it's
|
|
74
|
+
* unwrapped and the contents are returned AS-IS (no further processing).
|
|
75
|
+
* The contents represent user data that should not be modified.
|
|
76
|
+
*
|
|
77
|
+
* For regular objects and arrays, we recurse to find any nested escape markers.
|
|
78
|
+
*
|
|
79
|
+
* @param obj - The value to unescape.
|
|
80
|
+
* @returns The unescaped value.
|
|
81
|
+
*/
|
|
82
|
+
function unescapeValue(obj) {
|
|
83
|
+
if (obj !== null && typeof obj === "object" && !Array.isArray(obj)) {
|
|
84
|
+
const record = obj;
|
|
85
|
+
if (isEscapedObject(record)) return record[LC_ESCAPED_KEY];
|
|
86
|
+
const result = {};
|
|
87
|
+
for (const [key, value] of Object.entries(record)) result[key] = unescapeValue(value);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(obj)) return obj.map((item) => unescapeValue(item));
|
|
91
|
+
return obj;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
exports.escapeIfNeeded = escapeIfNeeded;
|
|
96
|
+
exports.isEscapedObject = isEscapedObject;
|
|
97
|
+
exports.unescapeValue = unescapeValue;
|
|
98
|
+
//# sourceMappingURL=validation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.cjs","names":["obj: Record<string, unknown>","obj: unknown","value: unknown","result: Record<string, unknown>"],"sources":["../../src/load/validation.ts"],"sourcesContent":["/**\n * Sentinel key used to mark escaped user objects during serialization.\n *\n * When a plain object contains 'lc' key (which could be confused with LC objects),\n * we wrap it as `{\"__lc_escaped__\": {...original...}}`.\n */\nexport const LC_ESCAPED_KEY = \"__lc_escaped__\";\n\n/**\n * Check if an object needs escaping to prevent confusion with LC objects.\n *\n * An object needs escaping if:\n * 1. It has an `'lc'` key (could be confused with LC serialization format)\n * 2. It has only the escape key (would be mistaken for an escaped object)\n */\nexport function needsEscaping(obj: Record<string, unknown>): boolean {\n return (\n \"lc\" in obj || (Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj)\n );\n}\n\n/**\n * Wrap an object in the escape marker.\n *\n * @example\n * ```typescript\n * {\"key\": \"value\"} // becomes {\"__lc_escaped__\": {\"key\": \"value\"}}\n * ```\n */\nexport function escapeObject(\n obj: Record<string, unknown>\n): Record<string, unknown> {\n return { [LC_ESCAPED_KEY]: obj };\n}\n\n/**\n * Check if an object is an escaped user object.\n *\n * @example\n * ```typescript\n * {\"__lc_escaped__\": {...}} // is an escaped object\n * ```\n */\nexport function isEscapedObject(obj: Record<string, unknown>): boolean {\n return Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj;\n}\n\n/**\n * Interface for objects that can be serialized.\n * This is a duck-typed interface to avoid circular imports.\n */\ninterface SerializableLike {\n lc_serializable: boolean;\n lc_secrets?: Record<string, string>;\n toJSON(): {\n lc: number;\n type: string;\n id: string[];\n kwargs?: Record<string, unknown>;\n };\n}\n\n/**\n * Check if an object looks like a Serializable instance (duck typing).\n */\nfunction isSerializableLike(obj: unknown): obj is SerializableLike {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"lc_serializable\" in obj &&\n typeof (obj as SerializableLike).toJSON === \"function\"\n );\n}\n\n/**\n * Create a \"not_implemented\" serialization result for objects that cannot be serialized.\n */\nfunction createNotImplemented(obj: unknown): {\n lc: 1;\n type: \"not_implemented\";\n id: string[];\n} {\n let id: string[];\n if (obj !== null && typeof obj === \"object\") {\n if (\"lc_id\" in obj && Array.isArray(obj.lc_id)) {\n id = obj.lc_id as string[];\n } else {\n id = [obj.constructor?.name ?? \"Object\"];\n }\n } else {\n id = [typeof obj];\n }\n return {\n lc: 1,\n type: \"not_implemented\",\n id,\n };\n}\n\n/**\n * Serialize a value with escaping of user objects.\n *\n * Called recursively on kwarg values to escape any plain objects that could be\n * confused with LC objects.\n *\n * @param obj - The value to serialize.\n * @returns The serialized value with user objects escaped as needed.\n */\nexport function serializeValue(obj: unknown): unknown {\n if (isSerializableLike(obj)) {\n // This is an LC object - serialize it properly (not escaped)\n return serializeLcObject(obj);\n }\n\n if (obj !== null && typeof obj === \"object\" && !Array.isArray(obj)) {\n const record = obj as Record<string, unknown>;\n // Check if object needs escaping BEFORE recursing into values.\n // If it needs escaping, wrap it as-is - the contents are user data that\n // will be returned as-is during deserialization (no instantiation).\n // This prevents re-escaping of already-escaped nested content.\n if (needsEscaping(record)) {\n return escapeObject(record);\n }\n // Safe object (no 'lc' key) - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = serializeValue(value);\n }\n return result;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => serializeValue(item));\n }\n\n if (\n typeof obj === \"string\" ||\n typeof obj === \"number\" ||\n typeof obj === \"boolean\" ||\n obj === null\n ) {\n return obj;\n }\n\n // Non-JSON-serializable object (Date, custom objects, etc.)\n return createNotImplemented(obj);\n}\n\n/**\n * Serialize a `Serializable` object with escaping of user data in kwargs.\n *\n * @param obj - The `Serializable` object to serialize.\n * @returns The serialized object with user data in kwargs escaped as needed.\n *\n * @remarks\n * Kwargs values are processed with `serializeValue` to escape user data (like\n * metadata) that contains `'lc'` keys. Secret fields (from `lc_secrets`) are\n * skipped because `toJSON()` replaces their values with secret markers.\n */\nexport function serializeLcObject(obj: SerializableLike): {\n lc: number;\n type: string;\n id: string[];\n kwargs?: Record<string, unknown>;\n} {\n // Secret fields are handled by toJSON() - it replaces values with secret markers\n const secretFields = new Set(Object.keys(obj.lc_secrets ?? {}));\n\n const serialized = { ...obj.toJSON() };\n\n // Process kwargs to escape user data that could be confused with LC objects\n // Skip secret fields - toJSON() already converted them to secret markers\n if (serialized.type === \"constructor\" && serialized.kwargs) {\n const newKwargs: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(serialized.kwargs)) {\n if (secretFields.has(key)) {\n newKwargs[key] = value;\n } else {\n newKwargs[key] = serializeValue(value);\n }\n }\n serialized.kwargs = newKwargs;\n }\n\n return serialized;\n}\n\n/**\n * Escape a value if it needs escaping (contains `lc` key).\n *\n * This is a simpler version of `serializeValue` that doesn't handle Serializable\n * objects - it's meant to be called on kwargs values that have already been\n * processed by `toJSON()`.\n *\n * @param value - The value to potentially escape.\n * @returns The value with any `lc`-containing objects wrapped in escape markers.\n */\nexport function escapeIfNeeded(value: unknown): unknown {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n // Preserve Serializable objects - they have their own toJSON() that will be\n // called by JSON.stringify. We don't want to convert them to plain objects.\n if (isSerializableLike(value)) {\n return value;\n }\n const record = value as Record<string, unknown>;\n // Check if object needs escaping BEFORE recursing into values.\n // If it needs escaping, wrap it as-is - the contents are user data that\n // will be returned as-is during deserialization (no instantiation).\n if (needsEscaping(record)) {\n return escapeObject(record);\n }\n // Safe object (no 'lc' key) - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(record)) {\n result[key] = escapeIfNeeded(val);\n }\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => escapeIfNeeded(item));\n }\n\n return value;\n}\n\n/**\n * Unescape a value, processing escape markers in object values and arrays.\n *\n * When an escaped object is encountered (`{\"__lc_escaped__\": ...}`), it's\n * unwrapped and the contents are returned AS-IS (no further processing).\n * The contents represent user data that should not be modified.\n *\n * For regular objects and arrays, we recurse to find any nested escape markers.\n *\n * @param obj - The value to unescape.\n * @returns The unescaped value.\n */\nexport function unescapeValue(obj: unknown): unknown {\n if (obj !== null && typeof obj === \"object\" && !Array.isArray(obj)) {\n const record = obj as Record<string, unknown>;\n if (isEscapedObject(record)) {\n // Unwrap and return the user data as-is (no further unescaping).\n // The contents are user data that may contain more escape keys,\n // but those are part of the user's actual data.\n return record[LC_ESCAPED_KEY];\n }\n\n // Regular object - recurse into values to find nested escape markers\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = unescapeValue(value);\n }\n return result;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => unescapeValue(item));\n }\n\n return obj;\n}\n"],"mappings":";;;;;;;;AAMA,MAA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CACpB,QAAO,IAAI,IAAI,CAAC,SAAS,cAAc,KAAK,CAAC;AAG/C,QAAO;AACR"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region src/load/validation.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sentinel key used to mark escaped user objects during serialization.
|
|
4
|
+
*
|
|
5
|
+
* When a plain object contains 'lc' key (which could be confused with LC objects),
|
|
6
|
+
* we wrap it as `{"__lc_escaped__": {...original...}}`.
|
|
7
|
+
*/
|
|
8
|
+
const LC_ESCAPED_KEY = "__lc_escaped__";
|
|
9
|
+
/**
|
|
10
|
+
* Check if an object needs escaping to prevent confusion with LC objects.
|
|
11
|
+
*
|
|
12
|
+
* An object needs escaping if:
|
|
13
|
+
* 1. It has an `'lc'` key (could be confused with LC serialization format)
|
|
14
|
+
* 2. It has only the escape key (would be mistaken for an escaped object)
|
|
15
|
+
*/
|
|
16
|
+
function needsEscaping(obj) {
|
|
17
|
+
return "lc" in obj || Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wrap an object in the escape marker.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* {"key": "value"} // becomes {"__lc_escaped__": {"key": "value"}}
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function escapeObject(obj) {
|
|
28
|
+
return { [LC_ESCAPED_KEY]: obj };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if an object is an escaped user object.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* {"__lc_escaped__": {...}} // is an escaped object
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function isEscapedObject(obj) {
|
|
39
|
+
return Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if an object looks like a Serializable instance (duck typing).
|
|
43
|
+
*/
|
|
44
|
+
function isSerializableLike(obj) {
|
|
45
|
+
return obj !== null && typeof obj === "object" && "lc_serializable" in obj && typeof obj.toJSON === "function";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Escape a value if it needs escaping (contains `lc` key).
|
|
49
|
+
*
|
|
50
|
+
* This is a simpler version of `serializeValue` that doesn't handle Serializable
|
|
51
|
+
* objects - it's meant to be called on kwargs values that have already been
|
|
52
|
+
* processed by `toJSON()`.
|
|
53
|
+
*
|
|
54
|
+
* @param value - The value to potentially escape.
|
|
55
|
+
* @returns The value with any `lc`-containing objects wrapped in escape markers.
|
|
56
|
+
*/
|
|
57
|
+
function escapeIfNeeded(value) {
|
|
58
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
59
|
+
if (isSerializableLike(value)) return value;
|
|
60
|
+
const record = value;
|
|
61
|
+
if (needsEscaping(record)) return escapeObject(record);
|
|
62
|
+
const result = {};
|
|
63
|
+
for (const [key, val] of Object.entries(record)) result[key] = escapeIfNeeded(val);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(value)) return value.map((item) => escapeIfNeeded(item));
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Unescape a value, processing escape markers in object values and arrays.
|
|
71
|
+
*
|
|
72
|
+
* When an escaped object is encountered (`{"__lc_escaped__": ...}`), it's
|
|
73
|
+
* unwrapped and the contents are returned AS-IS (no further processing).
|
|
74
|
+
* The contents represent user data that should not be modified.
|
|
75
|
+
*
|
|
76
|
+
* For regular objects and arrays, we recurse to find any nested escape markers.
|
|
77
|
+
*
|
|
78
|
+
* @param obj - The value to unescape.
|
|
79
|
+
* @returns The unescaped value.
|
|
80
|
+
*/
|
|
81
|
+
function unescapeValue(obj) {
|
|
82
|
+
if (obj !== null && typeof obj === "object" && !Array.isArray(obj)) {
|
|
83
|
+
const record = obj;
|
|
84
|
+
if (isEscapedObject(record)) return record[LC_ESCAPED_KEY];
|
|
85
|
+
const result = {};
|
|
86
|
+
for (const [key, value] of Object.entries(record)) result[key] = unescapeValue(value);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
if (Array.isArray(obj)) return obj.map((item) => unescapeValue(item));
|
|
90
|
+
return obj;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { escapeIfNeeded, isEscapedObject, unescapeValue };
|
|
95
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","names":["obj: Record<string, unknown>","obj: unknown","value: unknown","result: Record<string, unknown>"],"sources":["../../src/load/validation.ts"],"sourcesContent":["/**\n * Sentinel key used to mark escaped user objects during serialization.\n *\n * When a plain object contains 'lc' key (which could be confused with LC objects),\n * we wrap it as `{\"__lc_escaped__\": {...original...}}`.\n */\nexport const LC_ESCAPED_KEY = \"__lc_escaped__\";\n\n/**\n * Check if an object needs escaping to prevent confusion with LC objects.\n *\n * An object needs escaping if:\n * 1. It has an `'lc'` key (could be confused with LC serialization format)\n * 2. It has only the escape key (would be mistaken for an escaped object)\n */\nexport function needsEscaping(obj: Record<string, unknown>): boolean {\n return (\n \"lc\" in obj || (Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj)\n );\n}\n\n/**\n * Wrap an object in the escape marker.\n *\n * @example\n * ```typescript\n * {\"key\": \"value\"} // becomes {\"__lc_escaped__\": {\"key\": \"value\"}}\n * ```\n */\nexport function escapeObject(\n obj: Record<string, unknown>\n): Record<string, unknown> {\n return { [LC_ESCAPED_KEY]: obj };\n}\n\n/**\n * Check if an object is an escaped user object.\n *\n * @example\n * ```typescript\n * {\"__lc_escaped__\": {...}} // is an escaped object\n * ```\n */\nexport function isEscapedObject(obj: Record<string, unknown>): boolean {\n return Object.keys(obj).length === 1 && LC_ESCAPED_KEY in obj;\n}\n\n/**\n * Interface for objects that can be serialized.\n * This is a duck-typed interface to avoid circular imports.\n */\ninterface SerializableLike {\n lc_serializable: boolean;\n lc_secrets?: Record<string, string>;\n toJSON(): {\n lc: number;\n type: string;\n id: string[];\n kwargs?: Record<string, unknown>;\n };\n}\n\n/**\n * Check if an object looks like a Serializable instance (duck typing).\n */\nfunction isSerializableLike(obj: unknown): obj is SerializableLike {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"lc_serializable\" in obj &&\n typeof (obj as SerializableLike).toJSON === \"function\"\n );\n}\n\n/**\n * Create a \"not_implemented\" serialization result for objects that cannot be serialized.\n */\nfunction createNotImplemented(obj: unknown): {\n lc: 1;\n type: \"not_implemented\";\n id: string[];\n} {\n let id: string[];\n if (obj !== null && typeof obj === \"object\") {\n if (\"lc_id\" in obj && Array.isArray(obj.lc_id)) {\n id = obj.lc_id as string[];\n } else {\n id = [obj.constructor?.name ?? \"Object\"];\n }\n } else {\n id = [typeof obj];\n }\n return {\n lc: 1,\n type: \"not_implemented\",\n id,\n };\n}\n\n/**\n * Serialize a value with escaping of user objects.\n *\n * Called recursively on kwarg values to escape any plain objects that could be\n * confused with LC objects.\n *\n * @param obj - The value to serialize.\n * @returns The serialized value with user objects escaped as needed.\n */\nexport function serializeValue(obj: unknown): unknown {\n if (isSerializableLike(obj)) {\n // This is an LC object - serialize it properly (not escaped)\n return serializeLcObject(obj);\n }\n\n if (obj !== null && typeof obj === \"object\" && !Array.isArray(obj)) {\n const record = obj as Record<string, unknown>;\n // Check if object needs escaping BEFORE recursing into values.\n // If it needs escaping, wrap it as-is - the contents are user data that\n // will be returned as-is during deserialization (no instantiation).\n // This prevents re-escaping of already-escaped nested content.\n if (needsEscaping(record)) {\n return escapeObject(record);\n }\n // Safe object (no 'lc' key) - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = serializeValue(value);\n }\n return result;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => serializeValue(item));\n }\n\n if (\n typeof obj === \"string\" ||\n typeof obj === \"number\" ||\n typeof obj === \"boolean\" ||\n obj === null\n ) {\n return obj;\n }\n\n // Non-JSON-serializable object (Date, custom objects, etc.)\n return createNotImplemented(obj);\n}\n\n/**\n * Serialize a `Serializable` object with escaping of user data in kwargs.\n *\n * @param obj - The `Serializable` object to serialize.\n * @returns The serialized object with user data in kwargs escaped as needed.\n *\n * @remarks\n * Kwargs values are processed with `serializeValue` to escape user data (like\n * metadata) that contains `'lc'` keys. Secret fields (from `lc_secrets`) are\n * skipped because `toJSON()` replaces their values with secret markers.\n */\nexport function serializeLcObject(obj: SerializableLike): {\n lc: number;\n type: string;\n id: string[];\n kwargs?: Record<string, unknown>;\n} {\n // Secret fields are handled by toJSON() - it replaces values with secret markers\n const secretFields = new Set(Object.keys(obj.lc_secrets ?? {}));\n\n const serialized = { ...obj.toJSON() };\n\n // Process kwargs to escape user data that could be confused with LC objects\n // Skip secret fields - toJSON() already converted them to secret markers\n if (serialized.type === \"constructor\" && serialized.kwargs) {\n const newKwargs: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(serialized.kwargs)) {\n if (secretFields.has(key)) {\n newKwargs[key] = value;\n } else {\n newKwargs[key] = serializeValue(value);\n }\n }\n serialized.kwargs = newKwargs;\n }\n\n return serialized;\n}\n\n/**\n * Escape a value if it needs escaping (contains `lc` key).\n *\n * This is a simpler version of `serializeValue` that doesn't handle Serializable\n * objects - it's meant to be called on kwargs values that have already been\n * processed by `toJSON()`.\n *\n * @param value - The value to potentially escape.\n * @returns The value with any `lc`-containing objects wrapped in escape markers.\n */\nexport function escapeIfNeeded(value: unknown): unknown {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n // Preserve Serializable objects - they have their own toJSON() that will be\n // called by JSON.stringify. We don't want to convert them to plain objects.\n if (isSerializableLike(value)) {\n return value;\n }\n const record = value as Record<string, unknown>;\n // Check if object needs escaping BEFORE recursing into values.\n // If it needs escaping, wrap it as-is - the contents are user data that\n // will be returned as-is during deserialization (no instantiation).\n if (needsEscaping(record)) {\n return escapeObject(record);\n }\n // Safe object (no 'lc' key) - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(record)) {\n result[key] = escapeIfNeeded(val);\n }\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => escapeIfNeeded(item));\n }\n\n return value;\n}\n\n/**\n * Unescape a value, processing escape markers in object values and arrays.\n *\n * When an escaped object is encountered (`{\"__lc_escaped__\": ...}`), it's\n * unwrapped and the contents are returned AS-IS (no further processing).\n * The contents represent user data that should not be modified.\n *\n * For regular objects and arrays, we recurse to find any nested escape markers.\n *\n * @param obj - The value to unescape.\n * @returns The unescaped value.\n */\nexport function unescapeValue(obj: unknown): unknown {\n if (obj !== null && typeof obj === \"object\" && !Array.isArray(obj)) {\n const record = obj as Record<string, unknown>;\n if (isEscapedObject(record)) {\n // Unwrap and return the user data as-is (no further unescaping).\n // The contents are user data that may contain more escape keys,\n // but those are part of the user's actual data.\n return record[LC_ESCAPED_KEY];\n }\n\n // Regular object - recurse into values to find nested escape markers\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record)) {\n result[key] = unescapeValue(value);\n }\n return result;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => unescapeValue(item));\n }\n\n return obj;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,iBAAiB;;;;;;;;AAS9B,SAAgB,cAAcA,KAAuC;AACnE,QACE,QAAQ,OAAQ,OAAO,KAAK,IAAI,CAAC,WAAW,KAAK,kBAAkB;AAEtE;;;;;;;;;AAUD,SAAgB,aACdA,KACyB;AACzB,QAAO,GAAG,iBAAiB,IAAK;AACjC;;;;;;;;;AAUD,SAAgB,gBAAgBA,KAAuC;AACrE,QAAO,OAAO,KAAK,IAAI,CAAC,WAAW,KAAK,kBAAkB;AAC3D;;;;AAoBD,SAAS,mBAAmBC,KAAuC;AACjE,QACE,QAAQ,QACR,OAAO,QAAQ,YACf,qBAAqB,OACrB,OAAQ,IAAyB,WAAW;AAE/C;;;;;;;;;;;AA6HD,SAAgB,eAAeC,OAAyB;AACtD,KAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,EAAE;AAGxE,MAAI,mBAAmB,MAAM,CAC3B,QAAO;EAET,MAAM,SAAS;AAIf,MAAI,cAAc,OAAO,CACvB,QAAO,aAAa,OAAO;EAG7B,MAAMC,SAAkC,CAAE;AAC1C,OAAK,MAAM,CAAC,KAAK,IAAI,IAAI,OAAO,QAAQ,OAAO,EAC7C,OAAO,OAAO,eAAe,IAAI;AAEnC,SAAO;CACR;AAED,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,CAAC,SAAS,eAAe,KAAK,CAAC;AAGlD,QAAO;AACR;;;;;;;;;;;;;AAcD,SAAgB,cAAcF,KAAuB;AACnD,KAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI,EAAE;EAClE,MAAM,SAAS;AACf,MAAI,gBAAgB,OAAO,CAIzB,QAAO,OAAO;EAIhB,MAAME,SAAkC,CAAE;AAC1C,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,OAAO,EAC/C,OAAO,OAAO,cAAc,MAAM;AAEpC,SAAO;CACR;AAED,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,IAAI,CAAC,SAAS,cAAc,KAAK,CAAC;AAG/C,QAAO;AACR"}
|
package/dist/messages/base.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","names":["firstContent: MessageContent","secondContent: MessageContent","isDataContentBlock","left?: \"success\" | \"error\"","right?: \"success\" | \"error\"","obj: any","depthLimit: number","currentDepth: number","obj","result: Record<string, unknown>","Serializable","arg:\n | $InferMessageContent<TStructure, TRole>\n | BaseMessageFields<TStructure, TRole>","fields: BaseMessageFields<TStructure, TRole>","blocks: Array<ContentBlock>","convertToV1FromDataContent","convertToV1FromChatCompletionsInput","convertToV1FromAnthropicInput","blocks","obj: unknown","isMessage","value: string | undefined","depth: number | null","format: MessageStringFormat","convertToFormattedString","value?: unknown","left: Record<string, any>","right: Record<string, any>","left?: Content[]","right?: Content[]","left: T | undefined","right: T | undefined","x: BaseMessageLike","messageLike?: unknown"],"sources":["../../src/messages/base.ts"],"sourcesContent":["import { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { ContentBlock } from \"./content/index.js\";\nimport { isDataContentBlock } from \"./content/data.js\";\nimport { convertToV1FromAnthropicInput } from \"./block_translators/anthropic.js\";\nimport { convertToV1FromDataContent } from \"./block_translators/data.js\";\nimport { convertToV1FromChatCompletionsInput } from \"./block_translators/openai.js\";\nimport {\n $InferMessageContent,\n $InferResponseMetadata,\n MessageStructure,\n MessageType,\n isMessage,\n Message,\n} from \"./message.js\";\nimport {\n convertToFormattedString,\n type MessageStringFormat,\n} from \"./format.js\";\n\n/** @internal */\nconst MESSAGE_SYMBOL = Symbol.for(\"langchain.message\");\n\nexport interface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n response_metadata?: Record<string, any>;\n id?: string;\n}\n\nexport interface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\n\nexport interface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\n\nexport interface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\n\nexport type MessageContent = string | Array<ContentBlock>;\n\nexport interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n\n /**\n * The name of the function to call.\n */\n name: string;\n}\n\nexport type BaseMessageFields<\n TStructure extends MessageStructure = MessageStructure,\n TRole extends MessageType = MessageType\n> = {\n id?: string;\n name?: string;\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\n\nexport function mergeContent(\n firstContent: MessageContent,\n secondContent: MessageContent\n): MessageContent {\n // If first content is a string\n if (typeof firstContent === \"string\") {\n if (firstContent === \"\") {\n return secondContent;\n }\n if (typeof secondContent === \"string\") {\n return firstContent + secondContent;\n } else if (Array.isArray(secondContent) && secondContent.length === 0) {\n return firstContent;\n } else if (\n Array.isArray(secondContent) &&\n secondContent.some((c) => isDataContentBlock(c))\n ) {\n return [\n {\n type: \"text\",\n source_type: \"text\",\n text: firstContent,\n },\n ...secondContent,\n ];\n } else {\n return [{ type: \"text\", text: firstContent }, ...secondContent];\n }\n // If both are arrays\n } else if (Array.isArray(secondContent)) {\n return (\n _mergeLists(firstContent, secondContent) ?? [\n ...firstContent,\n ...secondContent,\n ]\n );\n } else {\n if (secondContent === \"\") {\n return firstContent;\n } else if (\n Array.isArray(firstContent) &&\n firstContent.some((c) => isDataContentBlock(c))\n ) {\n return [\n ...firstContent,\n {\n type: \"file\",\n source_type: \"text\",\n text: secondContent,\n },\n ];\n } else {\n return [...firstContent, { type: \"text\", text: secondContent }];\n }\n }\n}\n\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\nexport function _mergeStatus(\n left?: \"success\" | \"error\",\n right?: \"success\" | \"error\"\n): \"success\" | \"error\" | undefined {\n if (left === \"error\" || right === \"error\") {\n return \"error\";\n }\n return \"success\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction stringifyWithDepthLimit(obj: any, depthLimit: number): string {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function helper(obj: any, currentDepth: number): any {\n if (typeof obj !== \"object\" || obj === null || obj === undefined) {\n return obj;\n }\n if (currentDepth >= depthLimit) {\n if (Array.isArray(obj)) {\n return \"[Array]\";\n }\n return \"[Object]\";\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => helper(item, currentDepth + 1));\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n result[key] = helper(obj[key], currentDepth + 1);\n }\n return result;\n }\n\n return JSON.stringify(helper(obj, 0), null, 2);\n}\n\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\nexport abstract class BaseMessage<\n TStructure extends MessageStructure = MessageStructure,\n TRole extends MessageType = MessageType\n >\n extends Serializable\n implements Message<TStructure, TRole>\n{\n lc_namespace = [\"langchain_core\", \"messages\"];\n\n lc_serializable = true;\n\n get lc_aliases(): Record<string, string> {\n // exclude snake case conversion to pascal case\n return {\n additional_kwargs: \"additional_kwargs\",\n response_metadata: \"response_metadata\",\n };\n }\n\n readonly [MESSAGE_SYMBOL] = true as const;\n\n abstract readonly type: TRole;\n\n id?: string;\n\n name?: string;\n\n content: $InferMessageContent<TStructure, TRole>;\n\n additional_kwargs: NonNullable<\n BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]\n >;\n\n response_metadata: NonNullable<\n BaseMessageFields<TStructure, TRole>[\"response_metadata\"]\n >;\n\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType {\n return this.type;\n }\n\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType {\n return this._getType();\n }\n\n constructor(\n arg:\n | $InferMessageContent<TStructure, TRole>\n | BaseMessageFields<TStructure, TRole>\n ) {\n const fields: BaseMessageFields<TStructure, TRole> =\n typeof arg === \"string\" || Array.isArray(arg) ? { content: arg } : arg;\n if (!fields.additional_kwargs) {\n fields.additional_kwargs = {};\n }\n if (!fields.response_metadata) {\n fields.response_metadata = {};\n }\n super(fields);\n this.name = fields.name;\n if (fields.content === undefined && fields.contentBlocks !== undefined) {\n this.content = fields.contentBlocks as $InferMessageContent<\n TStructure,\n TRole\n >;\n this.response_metadata = {\n output_version: \"v1\",\n ...fields.response_metadata,\n };\n } else if (fields.content !== undefined) {\n this.content = fields.content ?? [];\n this.response_metadata = fields.response_metadata;\n } else {\n this.content = [] as $InferMessageContent<TStructure, TRole>;\n this.response_metadata = fields.response_metadata;\n }\n this.additional_kwargs = fields.additional_kwargs;\n this.id = fields.id;\n }\n\n /** Get text content of the message. */\n get text(): string {\n if (typeof this.content === \"string\") {\n return this.content;\n }\n if (!Array.isArray(this.content)) return \"\";\n return this.content\n .map((c) => {\n if (typeof c === \"string\") return c;\n if (c.type === \"text\") return c.text;\n return \"\";\n })\n .join(\"\");\n }\n\n get contentBlocks(): Array<ContentBlock.Standard> {\n const blocks: Array<ContentBlock> =\n typeof this.content === \"string\"\n ? [{ type: \"text\", text: this.content }]\n : this.content;\n const parsingSteps = [\n convertToV1FromDataContent,\n convertToV1FromChatCompletionsInput,\n convertToV1FromAnthropicInput,\n ];\n const parsedBlocks = parsingSteps.reduce(\n (blocks, step) => step(blocks),\n blocks\n );\n return parsedBlocks as Array<ContentBlock.Standard>;\n }\n\n toDict(): StoredMessage {\n return {\n type: this.getType(),\n data: (this.toJSON() as SerializedConstructor)\n .kwargs as StoredMessageData,\n };\n }\n\n static lc_name() {\n return \"BaseMessage\";\n }\n\n // Can't be protected for silly reasons\n get _printableFields(): Record<string, unknown> {\n return {\n id: this.id,\n content: this.content,\n name: this.name,\n additional_kwargs: this.additional_kwargs,\n response_metadata: this.response_metadata,\n };\n }\n\n static isInstance(obj: unknown): obj is BaseMessage {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n MESSAGE_SYMBOL in obj &&\n obj[MESSAGE_SYMBOL] === true &&\n isMessage(obj)\n );\n }\n\n // this private method is used to update the ID for the runtime\n // value as well as in lc_kwargs for serialisation\n _updateId(value: string | undefined) {\n this.id = value;\n\n // lc_attributes wouldn't work here, because jest compares the\n // whole object\n this.lc_kwargs.id = value;\n }\n\n get [Symbol.toStringTag]() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (this.constructor as any).lc_name();\n }\n\n // Override the default behavior of console.log\n [Symbol.for(\"nodejs.util.inspect.custom\")](depth: number | null) {\n if (depth === null) {\n return this;\n }\n const printable = stringifyWithDepthLimit(\n this._printableFields,\n Math.max(4, depth)\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return `${(this.constructor as any).lc_name()} ${printable}`;\n }\n\n toFormattedString(format: MessageStringFormat = \"pretty\"): string {\n return convertToFormattedString(this, format);\n }\n}\n\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\nexport type OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n\n index?: number;\n};\n\nexport function isOpenAIToolCallArray(\n value?: unknown\n): value is OpenAIToolCall[] {\n return (\n Array.isArray(value) &&\n value.every((v) => typeof (v as OpenAIToolCall).index === \"number\")\n );\n}\n\nexport function _mergeDicts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n left: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n right: Record<string, any> = {}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n const merged = { ...left };\n for (const [key, value] of Object.entries(right)) {\n if (merged[key] == null) {\n merged[key] = value;\n } else if (value == null) {\n continue;\n } else if (\n typeof merged[key] !== typeof value ||\n Array.isArray(merged[key]) !== Array.isArray(value)\n ) {\n throw new Error(\n `field[${key}] already exists in the message chunk, but with a different type.`\n );\n } else if (typeof merged[key] === \"string\") {\n if (key === \"type\") {\n // Do not merge 'type' fields\n continue;\n } else if (\n [\"id\", \"name\", \"output_version\", \"model_provider\"].includes(key)\n ) {\n // Keep the incoming value for these fields if its defined\n if (value) {\n merged[key] = value;\n }\n } else {\n merged[key] += value;\n }\n } else if (typeof merged[key] === \"object\" && !Array.isArray(merged[key])) {\n merged[key] = _mergeDicts(merged[key], value);\n } else if (Array.isArray(merged[key])) {\n merged[key] = _mergeLists(merged[key], value);\n } else if (merged[key] === value) {\n continue;\n } else {\n console.warn(\n `field[${key}] already exists in this message chunk and value has unsupported type.`\n );\n }\n }\n return merged;\n}\n\nexport function _mergeLists<Content extends ContentBlock>(\n left?: Content[],\n right?: Content[]\n): Content[] | undefined {\n if (left === undefined && right === undefined) {\n return undefined;\n } else if (left === undefined || right === undefined) {\n return left || right;\n } else {\n const merged = [...left];\n for (const item of right) {\n if (\n typeof item === \"object\" &&\n item !== null &&\n \"index\" in item &&\n typeof item.index === \"number\"\n ) {\n const toMerge = merged.findIndex((leftItem) => {\n const isObject = typeof leftItem === \"object\";\n const indiciesMatch =\n \"index\" in leftItem && leftItem.index === item.index;\n const idsMatch =\n \"id\" in leftItem && \"id\" in item && leftItem?.id === item?.id;\n const eitherItemMissingID =\n !(\"id\" in leftItem) ||\n !leftItem?.id ||\n !(\"id\" in item) ||\n !item?.id;\n return isObject && indiciesMatch && (idsMatch || eitherItemMissingID);\n });\n if (\n toMerge !== -1 &&\n typeof merged[toMerge] === \"object\" &&\n merged[toMerge] !== null\n ) {\n merged[toMerge] = _mergeDicts(\n merged[toMerge] as Record<string, unknown>,\n item as Record<string, unknown>\n ) as Content;\n } else {\n merged.push(item);\n }\n } else if (\n typeof item === \"object\" &&\n item !== null &&\n \"text\" in item &&\n item.text === \"\"\n ) {\n // No-op - skip empty text blocks\n continue;\n } else {\n merged.push(item);\n }\n }\n return merged;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _mergeObj<T = any>(\n left: T | undefined,\n right: T | undefined\n): T | undefined {\n if (left === undefined && right === undefined) {\n return undefined;\n }\n if (left === undefined || right === undefined) {\n return left ?? right;\n } else if (typeof left !== typeof right) {\n throw new Error(\n `Cannot merge objects of different types.\\nLeft ${typeof left}\\nRight ${typeof right}`\n );\n } else if (typeof left === \"string\" && typeof right === \"string\") {\n return (left + right) as T;\n } else if (Array.isArray(left) && Array.isArray(right)) {\n return _mergeLists(left, right) as T;\n } else if (typeof left === \"object\" && typeof right === \"object\") {\n return _mergeDicts(\n left as Record<string, unknown>,\n right as Record<string, unknown>\n ) as T;\n } else if (left === right) {\n return left;\n } else {\n throw new Error(\n `Can not merge objects of different types.\\nLeft ${left}\\nRight ${right}`\n );\n }\n}\n\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\nexport abstract class BaseMessageChunk<\n TStructure extends MessageStructure = MessageStructure,\n TRole extends MessageType = MessageType\n> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n\n static isInstance(obj: unknown): obj is BaseMessageChunk {\n if (!super.isInstance(obj)) {\n return false;\n }\n // Check if obj is an instance of BaseMessageChunk by traversing the prototype chain\n let proto = Object.getPrototypeOf(obj);\n while (proto !== null) {\n if (proto === BaseMessageChunk.prototype) {\n return true;\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n }\n}\n\nexport type MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\n\nexport function _isMessageFieldWithRole(\n x: BaseMessageLike\n): x is MessageFieldWithRole {\n return typeof (x as MessageFieldWithRole).role === \"string\";\n}\n\nexport type BaseMessageLike =\n | BaseMessage\n | MessageFieldWithRole\n | [MessageType, MessageContent]\n | string\n /**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */\n | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n } & BaseMessageFields &\n Record<string, unknown>)\n | SerializedConstructor;\n\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\nexport function isBaseMessage(\n messageLike?: unknown\n): messageLike is BaseMessage {\n return typeof (messageLike as BaseMessage)?._getType === \"function\";\n}\n\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\nexport function isBaseMessageChunk(\n messageLike?: unknown\n): messageLike is BaseMessageChunk {\n return BaseMessageChunk.isInstance(messageLike);\n}\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,iBAAiB,OAAO,IAAI,oBAAoB;AAuEtD,SAAgB,aACdA,cACAC,eACgB;AAEhB,KAAI,OAAO,iBAAiB,UAAU;AACpC,MAAI,iBAAiB,GACnB,QAAO;AAET,MAAI,OAAO,kBAAkB,SAC3B,QAAO,eAAe;WACb,MAAM,QAAQ,cAAc,IAAI,cAAc,WAAW,EAClE,QAAO;WAEP,MAAM,QAAQ,cAAc,IAC5B,cAAc,KAAK,CAAC,MAAMC,gCAAmB,EAAE,CAAC,CAEhD,QAAO,CACL;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACP,GACD,GAAG,aACJ;MAED,QAAO,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAc,GAAE,GAAG,aAAc;CAGlE,WAAU,MAAM,QAAQ,cAAc,CACrC,QACE,YAAY,cAAc,cAAc,IAAI,CAC1C,GAAG,cACH,GAAG,aACJ;UAGC,kBAAkB,GACpB,QAAO;UAEP,MAAM,QAAQ,aAAa,IAC3B,aAAa,KAAK,CAAC,MAAMA,gCAAmB,EAAE,CAAC,C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,EAAE,OAAO,KAAK,QAAQ,EAAE,OAAO,OAAO;UAE/E,OAAO,SAAS,YAAY,OAAO,UAAU,SACtD,QAAQ,OAAO;UACN,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,MAAM,CACpD,QAAO,YAAY,MAAM,MAAM;UACtB,OAAO,SAAS,YAAY,OAAO,UAAU,SACtD,QAAO,YACL,MACA,MACD;UACQ,SAAS,MAClB,QAAO;KAEP,OAAM,IAAI,MACR,CAAC,gDAAgD,EAAE,KAAK,QAAQ,EAAE,OAAO;AAG9E;;;;;;;;AASD,IAAsB,mBAAtB,MAAsB,yBAGZ,YAA+B;CAGvC,OAAO,WAAWZ,KAAuC;AACvD,MAAI,CAAC,MAAM,WAAW,IAAI,CACxB,QAAO;EAGT,IAAI,QAAQ,OAAO,eAAe,IAAI;AACtC,SAAO,UAAU,MAAM;AACrB,OAAI,UAAU,iBAAiB,UAC7B,QAAO;GAET,QAAQ,OAAO,eAAe,MAAM;EACrC;AACD,SAAO;CACR;AACF;AAQD,SAAgB,wBACda,GAC2B;AAC3B,QAAO,OAAQ,EAA2B,SAAS;AACpD;;;;AAmBD,SAAgB,cACdC,aAC4B;AAC5B,QAAO,OAAQ,aAA6B,aAAa;AAC1D;;;;AAKD,SAAgB,mBACdA,aACiC;AACjC,QAAO,iBAAiB,WAAW,YAAY;AAChD"}
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["firstContent: MessageContent","secondContent: MessageContent","isDataContentBlock","left?: \"success\" | \"error\"","right?: \"success\" | \"error\"","obj: any","depthLimit: number","currentDepth: number","obj","result: Record<string, unknown>","Serializable","arg:\n | $InferMessageContent<TStructure, TRole>\n | BaseMessageFields<TStructure, TRole>","fields: BaseMessageFields<TStructure, TRole>","blocks: Array<ContentBlock>","convertToV1FromDataContent","convertToV1FromChatCompletionsInput","convertToV1FromAnthropicInput","blocks","obj: unknown","isMessage","value: string | undefined","depth: number | null","format: MessageStringFormat","convertToFormattedString","value?: unknown","left: Record<string, any>","right: Record<string, any>","left?: Content[]","right?: Content[]","left: T | undefined","right: T | undefined","x: BaseMessageLike","messageLike?: unknown"],"sources":["../../src/messages/base.ts"],"sourcesContent":["import { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { ContentBlock } from \"./content/index.js\";\nimport { isDataContentBlock } from \"./content/data.js\";\nimport { convertToV1FromAnthropicInput } from \"./block_translators/anthropic.js\";\nimport { convertToV1FromDataContent } from \"./block_translators/data.js\";\nimport { convertToV1FromChatCompletionsInput } from \"./block_translators/openai.js\";\nimport {\n $InferMessageContent,\n $InferResponseMetadata,\n MessageStructure,\n MessageType,\n isMessage,\n Message,\n} from \"./message.js\";\nimport {\n convertToFormattedString,\n type MessageStringFormat,\n} from \"./format.js\";\n\n/** @internal */\nconst MESSAGE_SYMBOL = Symbol.for(\"langchain.message\");\n\nexport interface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n response_metadata?: Record<string, any>;\n id?: string;\n}\n\nexport interface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\n\nexport interface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\n\nexport interface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\n\nexport type MessageContent = string | Array<ContentBlock>;\n\nexport interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n\n /**\n * The name of the function to call.\n */\n name: string;\n}\n\nexport type BaseMessageFields<\n TStructure extends MessageStructure = MessageStructure,\n TRole extends MessageType = MessageType\n> = Pick<Message, \"id\" | \"name\"> & {\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\n\nexport function mergeContent(\n firstContent: MessageContent,\n secondContent: MessageContent\n): MessageContent {\n // If first content is a string\n if (typeof firstContent === \"string\") {\n if (firstContent === \"\") {\n return secondContent;\n }\n if (typeof secondContent === \"string\") {\n return firstContent + secondContent;\n } else if (Array.isArray(secondContent) && secondContent.length === 0) {\n return firstContent;\n } else if (\n Array.isArray(secondContent) &&\n secondContent.some((c) => isDataContentBlock(c))\n ) {\n return [\n {\n type: \"text\",\n source_type: \"text\",\n text: firstContent,\n },\n ...secondContent,\n ];\n } else {\n return [{ type: \"text\", text: firstContent }, ...secondContent];\n }\n // If both are arrays\n } else if (Array.isArray(secondContent)) {\n return (\n _mergeLists(firstContent, secondContent) ?? [\n ...firstContent,\n ...secondContent,\n ]\n );\n } else {\n if (secondContent === \"\") {\n return firstContent;\n } else if (\n Array.isArray(firstContent) &&\n firstContent.some((c) => isDataContentBlock(c))\n ) {\n return [\n ...firstContent,\n {\n type: \"file\",\n source_type: \"text\",\n text: secondContent,\n },\n ];\n } else {\n return [...firstContent, { type: \"text\", text: secondContent }];\n }\n }\n}\n\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\nexport function _mergeStatus(\n left?: \"success\" | \"error\",\n right?: \"success\" | \"error\"\n): \"success\" | \"error\" | undefined {\n if (left === \"error\" || right === \"error\") {\n return \"error\";\n }\n return \"success\";\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction stringifyWithDepthLimit(obj: any, depthLimit: number): string {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function helper(obj: any, currentDepth: number): any {\n if (typeof obj !== \"object\" || obj === null || obj === undefined) {\n return obj;\n }\n if (currentDepth >= depthLimit) {\n if (Array.isArray(obj)) {\n return \"[Array]\";\n }\n return \"[Object]\";\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => helper(item, currentDepth + 1));\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n result[key] = helper(obj[key], currentDepth + 1);\n }\n return result;\n }\n\n return JSON.stringify(helper(obj, 0), null, 2);\n}\n\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\nexport abstract class BaseMessage<\n TStructure extends MessageStructure = MessageStructure,\n TRole extends MessageType = MessageType\n >\n extends Serializable\n implements Message<TStructure, TRole>\n{\n lc_namespace = [\"langchain_core\", \"messages\"];\n\n lc_serializable = true;\n\n get lc_aliases(): Record<string, string> {\n // exclude snake case conversion to pascal case\n return {\n additional_kwargs: \"additional_kwargs\",\n response_metadata: \"response_metadata\",\n };\n }\n\n readonly [MESSAGE_SYMBOL] = true as const;\n\n abstract readonly type: TRole;\n\n id?: string;\n\n /** @inheritdoc */\n name?: string;\n\n content: $InferMessageContent<TStructure, TRole>;\n\n additional_kwargs: NonNullable<\n BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]\n >;\n\n response_metadata: NonNullable<\n BaseMessageFields<TStructure, TRole>[\"response_metadata\"]\n >;\n\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType {\n return this.type;\n }\n\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType {\n return this._getType();\n }\n\n constructor(\n arg:\n | $InferMessageContent<TStructure, TRole>\n | BaseMessageFields<TStructure, TRole>\n ) {\n const fields: BaseMessageFields<TStructure, TRole> =\n typeof arg === \"string\" || Array.isArray(arg) ? { content: arg } : arg;\n if (!fields.additional_kwargs) {\n fields.additional_kwargs = {};\n }\n if (!fields.response_metadata) {\n fields.response_metadata = {};\n }\n super(fields);\n this.name = fields.name;\n if (fields.content === undefined && fields.contentBlocks !== undefined) {\n this.content = fields.contentBlocks as $InferMessageContent<\n TStructure,\n TRole\n >;\n this.response_metadata = {\n output_version: \"v1\",\n ...fields.response_metadata,\n };\n } else if (fields.content !== undefined) {\n this.content = fields.content ?? [];\n this.response_metadata = fields.response_metadata;\n } else {\n this.content = [] as $InferMessageContent<TStructure, TRole>;\n this.response_metadata = fields.response_metadata;\n }\n this.additional_kwargs = fields.additional_kwargs;\n this.id = fields.id;\n }\n\n /** Get text content of the message. */\n get text(): string {\n if (typeof this.content === \"string\") {\n return this.content;\n }\n if (!Array.isArray(this.content)) return \"\";\n return this.content\n .map((c) => {\n if (typeof c === \"string\") return c;\n if (c.type === \"text\") return c.text;\n return \"\";\n })\n .join(\"\");\n }\n\n get contentBlocks(): Array<ContentBlock.Standard> {\n const blocks: Array<ContentBlock> =\n typeof this.content === \"string\"\n ? [{ type: \"text\", text: this.content }]\n : this.content;\n const parsingSteps = [\n convertToV1FromDataContent,\n convertToV1FromChatCompletionsInput,\n convertToV1FromAnthropicInput,\n ];\n const parsedBlocks = parsingSteps.reduce(\n (blocks, step) => step(blocks),\n blocks\n );\n return parsedBlocks as Array<ContentBlock.Standard>;\n }\n\n toDict(): StoredMessage {\n return {\n type: this.getType(),\n data: (this.toJSON() as SerializedConstructor)\n .kwargs as StoredMessageData,\n };\n }\n\n static lc_name() {\n return \"BaseMessage\";\n }\n\n // Can't be protected for silly reasons\n get _printableFields(): Record<string, unknown> {\n return {\n id: this.id,\n content: this.content,\n name: this.name,\n additional_kwargs: this.additional_kwargs,\n response_metadata: this.response_metadata,\n };\n }\n\n static isInstance(obj: unknown): obj is BaseMessage {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n MESSAGE_SYMBOL in obj &&\n obj[MESSAGE_SYMBOL] === true &&\n isMessage(obj)\n );\n }\n\n // this private method is used to update the ID for the runtime\n // value as well as in lc_kwargs for serialisation\n _updateId(value: string | undefined) {\n this.id = value;\n\n // lc_attributes wouldn't work here, because jest compares the\n // whole object\n this.lc_kwargs.id = value;\n }\n\n get [Symbol.toStringTag]() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (this.constructor as any).lc_name();\n }\n\n // Override the default behavior of console.log\n [Symbol.for(\"nodejs.util.inspect.custom\")](depth: number | null) {\n if (depth === null) {\n return this;\n }\n const printable = stringifyWithDepthLimit(\n this._printableFields,\n Math.max(4, depth)\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return `${(this.constructor as any).lc_name()} ${printable}`;\n }\n\n toFormattedString(format: MessageStringFormat = \"pretty\"): string {\n return convertToFormattedString(this, format);\n }\n}\n\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\nexport type OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n\n index?: number;\n};\n\nexport function isOpenAIToolCallArray(\n value?: unknown\n): value is OpenAIToolCall[] {\n return (\n Array.isArray(value) &&\n value.every((v) => typeof (v as OpenAIToolCall).index === \"number\")\n );\n}\n\nexport function _mergeDicts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n left: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n right: Record<string, any> = {}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n const merged = { ...left };\n for (const [key, value] of Object.entries(right)) {\n if (merged[key] == null) {\n merged[key] = value;\n } else if (value == null) {\n continue;\n } else if (\n typeof merged[key] !== typeof value ||\n Array.isArray(merged[key]) !== Array.isArray(value)\n ) {\n throw new Error(\n `field[${key}] already exists in the message chunk, but with a different type.`\n );\n } else if (typeof merged[key] === \"string\") {\n if (key === \"type\") {\n // Do not merge 'type' fields\n continue;\n } else if (\n [\"id\", \"name\", \"output_version\", \"model_provider\"].includes(key)\n ) {\n // Keep the incoming value for these fields if its defined\n if (value) {\n merged[key] = value;\n }\n } else {\n merged[key] += value;\n }\n } else if (typeof merged[key] === \"object\" && !Array.isArray(merged[key])) {\n merged[key] = _mergeDicts(merged[key], value);\n } else if (Array.isArray(merged[key])) {\n merged[key] = _mergeLists(merged[key], value);\n } else if (merged[key] === value) {\n continue;\n } else {\n console.warn(\n `field[${key}] already exists in this message chunk and value has unsupported type.`\n );\n }\n }\n return merged;\n}\n\nexport function _mergeLists<Content extends ContentBlock>(\n left?: Content[],\n right?: Content[]\n): Content[] | undefined {\n if (left === undefined && right === undefined) {\n return undefined;\n } else if (left === undefined || right === undefined) {\n return left || right;\n } else {\n const merged = [...left];\n for (const item of right) {\n if (\n typeof item === \"object\" &&\n item !== null &&\n \"index\" in item &&\n typeof item.index === \"number\"\n ) {\n const toMerge = merged.findIndex((leftItem) => {\n const isObject = typeof leftItem === \"object\";\n const indiciesMatch =\n \"index\" in leftItem && leftItem.index === item.index;\n const idsMatch =\n \"id\" in leftItem && \"id\" in item && leftItem?.id === item?.id;\n const eitherItemMissingID =\n !(\"id\" in leftItem) ||\n !leftItem?.id ||\n !(\"id\" in item) ||\n !item?.id;\n return isObject && indiciesMatch && (idsMatch || eitherItemMissingID);\n });\n if (\n toMerge !== -1 &&\n typeof merged[toMerge] === \"object\" &&\n merged[toMerge] !== null\n ) {\n merged[toMerge] = _mergeDicts(\n merged[toMerge] as Record<string, unknown>,\n item as Record<string, unknown>\n ) as Content;\n } else {\n merged.push(item);\n }\n } else if (\n typeof item === \"object\" &&\n item !== null &&\n \"text\" in item &&\n item.text === \"\"\n ) {\n // No-op - skip empty text blocks\n continue;\n } else {\n merged.push(item);\n }\n }\n return merged;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _mergeObj<T = any>(\n left: T | undefined,\n right: T | undefined\n): T | undefined {\n if (left === undefined && right === undefined) {\n return undefined;\n }\n if (left === undefined || right === undefined) {\n return left ?? right;\n } else if (typeof left !== typeof right) {\n throw new Error(\n `Cannot merge objects of different types.\\nLeft ${typeof left}\\nRight ${typeof right}`\n );\n } else if (typeof left === \"string\" && typeof right === \"string\") {\n return (left + right) as T;\n } else if (Array.isArray(left) && Array.isArray(right)) {\n return _mergeLists(left, right) as T;\n } else if (typeof left === \"object\" && typeof right === \"object\") {\n return _mergeDicts(\n left as Record<string, unknown>,\n right as Record<string, unknown>\n ) as T;\n } else if (left === right) {\n return left;\n } else {\n throw new Error(\n `Can not merge objects of different types.\\nLeft ${left}\\nRight ${right}`\n );\n }\n}\n\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\nexport abstract class BaseMessageChunk<\n TStructure extends MessageStructure = MessageStructure,\n TRole extends MessageType = MessageType\n> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n\n static isInstance(obj: unknown): obj is BaseMessageChunk {\n if (!super.isInstance(obj)) {\n return false;\n }\n // Check if obj is an instance of BaseMessageChunk by traversing the prototype chain\n let proto = Object.getPrototypeOf(obj);\n while (proto !== null) {\n if (proto === BaseMessageChunk.prototype) {\n return true;\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n }\n}\n\nexport type MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\n\nexport function _isMessageFieldWithRole(\n x: BaseMessageLike\n): x is MessageFieldWithRole {\n return typeof (x as MessageFieldWithRole).role === \"string\";\n}\n\nexport type BaseMessageLike =\n | BaseMessage\n | MessageFieldWithRole\n | [MessageType, MessageContent]\n | string\n /**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */\n | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n } & BaseMessageFields &\n Record<string, unknown>)\n | SerializedConstructor;\n\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\nexport function isBaseMessage(\n messageLike?: unknown\n): messageLike is BaseMessage {\n return typeof (messageLike as BaseMessage)?._getType === \"function\";\n}\n\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\nexport function isBaseMessageChunk(\n messageLike?: unknown\n): messageLike is BaseMessageChunk {\n return BaseMessageChunk.isInstance(messageLike);\n}\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,iBAAiB,OAAO,IAAI,oBAAoB;AAqEtD,SAAgB,aACdA,cACAC,eACgB;AAEhB,KAAI,OAAO,iBAAiB,UAAU;AACpC,MAAI,iBAAiB,GACnB,QAAO;AAET,MAAI,OAAO,kBAAkB,SAC3B,QAAO,eAAe;WACb,MAAM,QAAQ,cAAc,IAAI,cAAc,WAAW,EAClE,QAAO;WAEP,MAAM,QAAQ,cAAc,IAC5B,cAAc,KAAK,CAAC,MAAMC,gCAAmB,EAAE,CAAC,CAEhD,QAAO,CACL;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACP,GACD,GAAG,aACJ;MAED,QAAO,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAc,GAAE,GAAG,aAAc;CAGlE,WAAU,MAAM,QAAQ,cAAc,CACrC,QACE,YAAY,cAAc,cAAc,IAAI,CAC1C,GAAG,cACH,GAAG,aACJ;UAGC,kBAAkB,GACpB,QAAO;UAEP,MAAM,QAAQ,aAAa,IAC3B,aAAa,KAAK,CAAC,MAAMA,gCAAmB,EAAE,CAAC,CAE/C,QAAO,CACL,GAAG,cACH;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACP,C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AAY,OAAO,UAAU,SACtD,QAAQ,OAAO;UACN,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,MAAM,CACpD,QAAO,YAAY,MAAM,MAAM;UACtB,OAAO,SAAS,YAAY,OAAO,UAAU,SACtD,QAAO,YACL,MACA,MACD;UACQ,SAAS,MAClB,QAAO;KAEP,OAAM,IAAI,MACR,CAAC,gDAAgD,EAAE,KAAK,QAAQ,EAAE,OAAO;AAG9E;;;;;;;;AASD,IAAsB,mBAAtB,MAAsB,yBAGZ,YAA+B;CAGvC,OAAO,WAAWZ,KAAuC;AACvD,MAAI,CAAC,MAAM,WAAW,IAAI,CACxB,QAAO;EAGT,IAAI,QAAQ,OAAO,eAAe,IAAI;AACtC,SAAO,UAAU,MAAM;AACrB,OAAI,UAAU,iBAAiB,UAC7B,QAAO;GAET,QAAQ,OAAO,eAAe,MAAM;EACrC;AACD,SAAO;CACR;AACF;AAQD,SAAgB,wBACda,GAC2B;AAC3B,QAAO,OAAQ,EAA2B,SAAS;AACpD;;;;AAmBD,SAAgB,cACdC,aAC4B;AAC5B,QAAO,OAAQ,aAA6B,aAAa;AAC1D;;;;AAKD,SAAgB,mBACdA,aACiC;AACjC,QAAO,iBAAiB,WAAW,YAAY;AAChD"}
|
package/dist/messages/base.d.cts
CHANGED
|
@@ -43,9 +43,7 @@ interface FunctionCall {
|
|
|
43
43
|
*/
|
|
44
44
|
name: string;
|
|
45
45
|
}
|
|
46
|
-
type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = {
|
|
47
|
-
id?: string;
|
|
48
|
-
name?: string;
|
|
46
|
+
type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = Pick<Message, "id" | "name"> & {
|
|
49
47
|
content?: $InferMessageContent<TStructure, TRole>;
|
|
50
48
|
contentBlocks?: Array<ContentBlock.Standard>;
|
|
51
49
|
/** @deprecated */
|
|
@@ -84,6 +82,7 @@ declare abstract class BaseMessage<TStructure extends MessageStructure = Message
|
|
|
84
82
|
readonly [MESSAGE_SYMBOL]: true;
|
|
85
83
|
abstract readonly type: TRole;
|
|
86
84
|
id?: string;
|
|
85
|
+
/** @inheritdoc */
|
|
87
86
|
name?: string;
|
|
88
87
|
content: $InferMessageContent<TStructure, TRole>;
|
|
89
88
|
additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>["additional_kwargs"]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":["Serializable","SerializedConstructor","ContentBlock","$InferMessageContent","$InferResponseMetadata","MessageStructure","MessageType","Message","MessageStringFormat","MESSAGE_SYMBOL","StoredMessageData","Record","StoredMessage","StoredGeneration","StoredMessageV1","MessageContent","Array","FunctionCall","BaseMessageFields","TStructure","TRole","Standard","OpenAIToolCall","Partial","mergeContent","_mergeStatus","BaseMessage","NonNullable","Symbol","toStringTag","isOpenAIToolCallArray","_mergeDicts","_mergeLists","Content","_mergeObj","T","BaseMessageChunk","MessageFieldWithRole","_isMessageFieldWithRole","BaseMessageLike","isBaseMessage","isBaseMessageChunk"],"sources":["../../src/messages/base.d.ts"],"sourcesContent":["import { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { ContentBlock } from \"./content/index.js\";\nimport { $InferMessageContent, $InferResponseMetadata, MessageStructure, MessageType, Message } from \"./message.js\";\nimport { type MessageStringFormat } from \"./format.js\";\n/** @internal */\ndeclare const MESSAGE_SYMBOL: unique symbol;\nexport interface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n response_metadata?: Record<string, any>;\n id?: string;\n}\nexport interface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\nexport interface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\nexport interface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\nexport type MessageContent = string | Array<ContentBlock>;\nexport interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n /**\n * The name of the function to call.\n */\n name: string;\n}\nexport type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = {\n id?: string;\n name?: string;\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\nexport declare function mergeContent(firstContent: MessageContent, secondContent: MessageContent): MessageContent;\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\nexport declare function _mergeStatus(left?: \"success\" | \"error\", right?: \"success\" | \"error\"): \"success\" | \"error\" | undefined;\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\nexport declare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {\n lc_namespace: string[];\n lc_serializable: boolean;\n get lc_aliases(): Record<string, string>;\n readonly [MESSAGE_SYMBOL]: true;\n abstract readonly type: TRole;\n id?: string;\n name?: string;\n content: $InferMessageContent<TStructure, TRole>;\n additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]>;\n response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>[\"response_metadata\"]>;\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType;\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType;\n constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);\n /** Get text content of the message. */\n get text(): string;\n get contentBlocks(): Array<ContentBlock.Standard>;\n toDict(): StoredMessage;\n static lc_name(): string;\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is BaseMessage;\n _updateId(value: string | undefined): void;\n get [Symbol.toStringTag](): any;\n toFormattedString(format?: MessageStringFormat): string;\n}\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\nexport type OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n index?: number;\n};\nexport declare function isOpenAIToolCallArray(value?: unknown): value is OpenAIToolCall[];\nexport declare function _mergeDicts(left?: Record<string, any>, right?: Record<string, any>): Record<string, any>;\nexport declare function _mergeLists<Content extends ContentBlock>(left?: Content[], right?: Content[]): Content[] | undefined;\nexport declare function _mergeObj<T = any>(left: T | undefined, right: T | undefined): T | undefined;\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\nexport declare abstract class BaseMessageChunk<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n static isInstance(obj: unknown): obj is BaseMessageChunk;\n}\nexport type MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\nexport declare function _isMessageFieldWithRole(x: BaseMessageLike): x is MessageFieldWithRole;\nexport type BaseMessageLike = BaseMessage | MessageFieldWithRole | [MessageType, MessageContent] | string\n/**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */\n | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n} & BaseMessageFields & Record<string, unknown>) | SerializedConstructor;\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\nexport declare function isBaseMessage(messageLike?: unknown): messageLike is BaseMessage;\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\nexport declare function isBaseMessageChunk(messageLike?: unknown): messageLike is BaseMessageChunk;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;cAKcS;AAAAA,UACGC,iBAAAA,CAD0B;EAC1BA,OAAAA,EAAAA,MAAAA;EAUAE,IAAAA,EAAAA,MAAAA,GAAAA,SAAa;EAIbC,IAAAA,EAAAA,MAAAA,GAAAA,SAAgB;EAIhBC,YAAAA,EAAAA,MAAe,GAAA,SAAA;EAKpBC,iBAAc,CAAA,EAlBFJ,MAkBE,CAAA,MAAkBT,EAAAA,GAAAA,CAAAA;EAC3Be;EAaLC,iBAAAA,CAAAA,EA9BYP,MA8BK,CAAAQ,MAAAA,EAAAA,GAAAA,CAAAC;EAAoBf,EAAAA,CAAAA,EAAAA,MAAAA;;AAAmDC,UA3BnFM,aAAAA,CA2BmFN;EAAcA,IAAAA,EAAAA,MAAAA;EAG/Ea,IAAAA,EA5BzBT,iBA4ByBS;;AAArBhB,UA1BGU,gBAAAA,CA0BHV;EACYD,IAAAA,EAAAA,MAAamB;EAAnBL,OAAAA,CAAAA,EAzBNJ,aAyBMI;;AAUCM,UAjCJR,eAAAA,CAiCIQ;EAGkCH,IAAAA,EAAAA,MAAAA;EAAYC,IAAAA,EAAAA,MAAAA,GAAAA,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,kBAAAA,wCAA0DL"}
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":["Serializable","SerializedConstructor","ContentBlock","$InferMessageContent","$InferResponseMetadata","MessageStructure","MessageType","Message","MessageStringFormat","MESSAGE_SYMBOL","StoredMessageData","Record","StoredMessage","StoredGeneration","StoredMessageV1","MessageContent","Array","FunctionCall","BaseMessageFields","TStructure","TRole","Pick","Standard","OpenAIToolCall","Partial","mergeContent","_mergeStatus","BaseMessage","NonNullable","Symbol","toStringTag","isOpenAIToolCallArray","_mergeDicts","_mergeLists","Content","_mergeObj","T","BaseMessageChunk","MessageFieldWithRole","_isMessageFieldWithRole","BaseMessageLike","isBaseMessage","isBaseMessageChunk"],"sources":["../../src/messages/base.d.ts"],"sourcesContent":["import { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { ContentBlock } from \"./content/index.js\";\nimport { $InferMessageContent, $InferResponseMetadata, MessageStructure, MessageType, Message } from \"./message.js\";\nimport { type MessageStringFormat } from \"./format.js\";\n/** @internal */\ndeclare const MESSAGE_SYMBOL: unique symbol;\nexport interface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n response_metadata?: Record<string, any>;\n id?: string;\n}\nexport interface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\nexport interface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\nexport interface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\nexport type MessageContent = string | Array<ContentBlock>;\nexport interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n /**\n * The name of the function to call.\n */\n name: string;\n}\nexport type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = Pick<Message, \"id\" | \"name\"> & {\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\nexport declare function mergeContent(firstContent: MessageContent, secondContent: MessageContent): MessageContent;\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\nexport declare function _mergeStatus(left?: \"success\" | \"error\", right?: \"success\" | \"error\"): \"success\" | \"error\" | undefined;\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\nexport declare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {\n lc_namespace: string[];\n lc_serializable: boolean;\n get lc_aliases(): Record<string, string>;\n readonly [MESSAGE_SYMBOL]: true;\n abstract readonly type: TRole;\n id?: string;\n /** @inheritdoc */\n name?: string;\n content: $InferMessageContent<TStructure, TRole>;\n additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]>;\n response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>[\"response_metadata\"]>;\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType;\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType;\n constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);\n /** Get text content of the message. */\n get text(): string;\n get contentBlocks(): Array<ContentBlock.Standard>;\n toDict(): StoredMessage;\n static lc_name(): string;\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is BaseMessage;\n _updateId(value: string | undefined): void;\n get [Symbol.toStringTag](): any;\n toFormattedString(format?: MessageStringFormat): string;\n}\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\nexport type OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n index?: number;\n};\nexport declare function isOpenAIToolCallArray(value?: unknown): value is OpenAIToolCall[];\nexport declare function _mergeDicts(left?: Record<string, any>, right?: Record<string, any>): Record<string, any>;\nexport declare function _mergeLists<Content extends ContentBlock>(left?: Content[], right?: Content[]): Content[] | undefined;\nexport declare function _mergeObj<T = any>(left: T | undefined, right: T | undefined): T | undefined;\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\nexport declare abstract class BaseMessageChunk<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n static isInstance(obj: unknown): obj is BaseMessageChunk;\n}\nexport type MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\nexport declare function _isMessageFieldWithRole(x: BaseMessageLike): x is MessageFieldWithRole;\nexport type BaseMessageLike = BaseMessage | MessageFieldWithRole | [MessageType, MessageContent] | string\n/**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */\n | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n} & BaseMessageFields & Record<string, unknown>) | SerializedConstructor;\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\nexport declare function isBaseMessage(messageLike?: unknown): messageLike is BaseMessage;\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\nexport declare function isBaseMessageChunk(messageLike?: unknown): messageLike is BaseMessageChunk;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;cAKcS;AAAAA,UACGC,iBAAAA,CAD0B;EAC1BA,OAAAA,EAAAA,MAAAA;EAUAE,IAAAA,EAAAA,MAAAA,GAAAA,SAAa;EAIbC,IAAAA,EAAAA,MAAAA,GAAAA,SAAgB;EAIhBC,YAAAA,EAAAA,MAAe,GAAA,SAAA;EAKpBC,iBAAc,CAAA,EAlBFJ,MAkBE,CAAA,MAAkBT,EAAAA,GAAAA,CAAAA;EAC3Be;EAaLC,iBAAAA,CAAAA,EA9BYP,MA8BK,CAAAQ,MAAAA,EAAAA,GAAAA,CAAAC;EAAoBf,EAAAA,CAAAA,EAAAA,MAAAA;;AAAmDC,UA3BnFM,aAAAA,CA2BmFN;EAAcA,IAAAA,EAAAA,MAAAA;EAAoBC,IAAAA,EAzB5HG,iBAyB4HH;;AACnGY,UAxBlBN,gBAAAA,CAwBkBM;EAAYC,IAAAA,EAAAA,MAAAA;EAAjCjB,OAAAA,CAAAA,EAtBAS,aAsBAT;;AACMa,UArBHF,eAAAA,CAqBGE;EAMIC,IAAAA,EAAAA,MAAAA;EAIHM,IAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAGkCJ,IAAAA,EAAAA,MAAAA;;AAAvBf,KA7BpBW,cAAAA,GA6BoBX,MAAAA,GA7BMY,KA6BNZ,CA7BYF,YA6BZE,CAAAA;AAARoB,UA5BPP,YAAAA,CA4BOO;EAAO;AAE/B;;;;AAAiH;EASzFE,SAAAA,EAAAA,MAAY;EAMNC;;;EAAkFrB,I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AAA,MAAoB;EACtBhC,IAAAA,gBAAAA,CAAAA,CAAAA,EAxCkBK,MAwClBL,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EACGS,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAxC+BY,WAwC/BZ;EAETJ,SAAAA,CAAAA,KAAAA,EAAAA,MAAAA,GAAAA,SAAAA,CAAAA,EAAAA,IAAAA;EAAM,KAxCDkB,MAAAA,CAAOC,WAAAA,GAwCN,EAAA,GAAA;EACcS,iBAAAA,CAAAA,MAA2BC,CAA3BD,EAxCO/B,mBAwCoBgC,CAAAA,EAAAA,MAAAA;AACnD;;;;AAAiFzB,KApCrEQ,cAAAA,GAoCqER;EAKvET;;;EACyCL,EAAAA,EAAAA,MAAAA;EAAqB;AAIxE;AAIA;YA1CcgB;;;;;;;iBAOUc,qBAAAA,4BAAiDR;iBACjDS,WAAAA,QAAmBrB,6BAA6BA,sBAAsBA;iBACtEsB,4BAA4B/B,qBAAqBgC,mBAAmBA,YAAYA;iBAChFC,yBAAyBC,sBAAsBA,gBAAgBA;;;;;;;;uBAQzDC,oCAAoChC,mBAAmBA,gCAAgCC,cAAcA,qBAAqBqB,YAAYR,YAAYC;yBACrJiB,mBAAmBA,iBAAiBlB,YAAYC;0CAC/BiB;;KAEhCC,oBAAAA;QACFhC;WACGS;;IAETJ;iBACoB4B,uBAAAA,IAA2BC,uBAAuBF;KAC9DE,eAAAA,GAAkBb,cAAcW,wBAAwBhC,aAAaS;;;;QAKvET;IACNY,oBAAoBP,2BAA2BV;;;;iBAI3BwC,aAAAA,wCAAqDd;;;;iBAIrDe,kBAAAA,wCAA0DL"}
|
package/dist/messages/base.d.ts
CHANGED
|
@@ -43,9 +43,7 @@ interface FunctionCall {
|
|
|
43
43
|
*/
|
|
44
44
|
name: string;
|
|
45
45
|
}
|
|
46
|
-
type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = {
|
|
47
|
-
id?: string;
|
|
48
|
-
name?: string;
|
|
46
|
+
type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = Pick<Message, "id" | "name"> & {
|
|
49
47
|
content?: $InferMessageContent<TStructure, TRole>;
|
|
50
48
|
contentBlocks?: Array<ContentBlock.Standard>;
|
|
51
49
|
/** @deprecated */
|
|
@@ -84,6 +82,7 @@ declare abstract class BaseMessage<TStructure extends MessageStructure = Message
|
|
|
84
82
|
readonly [MESSAGE_SYMBOL]: true;
|
|
85
83
|
abstract readonly type: TRole;
|
|
86
84
|
id?: string;
|
|
85
|
+
/** @inheritdoc */
|
|
87
86
|
name?: string;
|
|
88
87
|
content: $InferMessageContent<TStructure, TRole>;
|
|
89
88
|
additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>["additional_kwargs"]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":["Serializable","SerializedConstructor","ContentBlock","$InferMessageContent","$InferResponseMetadata","MessageStructure","MessageType","Message","MessageStringFormat","MESSAGE_SYMBOL","StoredMessageData","Record","StoredMessage","StoredGeneration","StoredMessageV1","MessageContent","Array","FunctionCall","BaseMessageFields","TStructure","TRole","Standard","OpenAIToolCall","Partial","mergeContent","_mergeStatus","BaseMessage","NonNullable","Symbol","toStringTag","isOpenAIToolCallArray","_mergeDicts","_mergeLists","Content","_mergeObj","T","BaseMessageChunk","MessageFieldWithRole","_isMessageFieldWithRole","BaseMessageLike","isBaseMessage","isBaseMessageChunk"],"sources":["../../src/messages/base.d.ts"],"sourcesContent":["import { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { ContentBlock } from \"./content/index.js\";\nimport { $InferMessageContent, $InferResponseMetadata, MessageStructure, MessageType, Message } from \"./message.js\";\nimport { type MessageStringFormat } from \"./format.js\";\n/** @internal */\ndeclare const MESSAGE_SYMBOL: unique symbol;\nexport interface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n response_metadata?: Record<string, any>;\n id?: string;\n}\nexport interface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\nexport interface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\nexport interface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\nexport type MessageContent = string | Array<ContentBlock>;\nexport interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n /**\n * The name of the function to call.\n */\n name: string;\n}\nexport type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = {\n id?: string;\n name?: string;\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\nexport declare function mergeContent(firstContent: MessageContent, secondContent: MessageContent): MessageContent;\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\nexport declare function _mergeStatus(left?: \"success\" | \"error\", right?: \"success\" | \"error\"): \"success\" | \"error\" | undefined;\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\nexport declare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {\n lc_namespace: string[];\n lc_serializable: boolean;\n get lc_aliases(): Record<string, string>;\n readonly [MESSAGE_SYMBOL]: true;\n abstract readonly type: TRole;\n id?: string;\n name?: string;\n content: $InferMessageContent<TStructure, TRole>;\n additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]>;\n response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>[\"response_metadata\"]>;\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType;\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType;\n constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);\n /** Get text content of the message. */\n get text(): string;\n get contentBlocks(): Array<ContentBlock.Standard>;\n toDict(): StoredMessage;\n static lc_name(): string;\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is BaseMessage;\n _updateId(value: string | undefined): void;\n get [Symbol.toStringTag](): any;\n toFormattedString(format?: MessageStringFormat): string;\n}\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\nexport type OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n index?: number;\n};\nexport declare function isOpenAIToolCallArray(value?: unknown): value is OpenAIToolCall[];\nexport declare function _mergeDicts(left?: Record<string, any>, right?: Record<string, any>): Record<string, any>;\nexport declare function _mergeLists<Content extends ContentBlock>(left?: Content[], right?: Content[]): Content[] | undefined;\nexport declare function _mergeObj<T = any>(left: T | undefined, right: T | undefined): T | undefined;\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\nexport declare abstract class BaseMessageChunk<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n static isInstance(obj: unknown): obj is BaseMessageChunk;\n}\nexport type MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\nexport declare function _isMessageFieldWithRole(x: BaseMessageLike): x is MessageFieldWithRole;\nexport type BaseMessageLike = BaseMessage | MessageFieldWithRole | [MessageType, MessageContent] | string\n/**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */\n | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n} & BaseMessageFields & Record<string, unknown>) | SerializedConstructor;\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\nexport declare function isBaseMessage(messageLike?: unknown): messageLike is BaseMessage;\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\nexport declare function isBaseMessageChunk(messageLike?: unknown): messageLike is BaseMessageChunk;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;cAKcS;AAAAA,UACGC,iBAAAA,CAD0B;EAC1BA,OAAAA,EAAAA,MAAAA;EAUAE,IAAAA,EAAAA,MAAAA,GAAAA,SAAa;EAIbC,IAAAA,EAAAA,MAAAA,GAAAA,SAAgB;EAIhBC,YAAAA,EAAAA,MAAe,GAAA,SAAA;EAKpBC,iBAAc,CAAA,EAlBFJ,MAkBE,CAAA,MAAkBT,EAAAA,GAAAA,CAAAA;EAC3Be;EAaLC,iBAAAA,CAAAA,EA9BYP,MA8BK,CAAAQ,MAAAA,EAAAA,GAAAA,CAAAC;EAAoBf,EAAAA,CAAAA,EAAAA,MAAAA;;AAAmDC,UA3BnFM,aAAAA,CA2BmFN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oB,YAAYP,YAAYC;yBACrJgB,mBAAmBA,iBAAiBjB,YAAYC;0CAC/BgB;;KAEhCC,oBAAAA;QACF/B;WACGS;;IAETJ;iBACoB2B,uBAAAA,IAA2BC,uBAAuBF;KAC9DE,eAAAA,GAAkBb,cAAcW,wBAAwB/B,aAAaS;;;;QAKvET;IACNY,oBAAoBP,2BAA2BV;;;;iBAI3BuC,aAAAA,wCAAqDd;;;;iBAIrDe,kBAAAA,wCAA0DL"}
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":["Serializable","SerializedConstructor","ContentBlock","$InferMessageContent","$InferResponseMetadata","MessageStructure","MessageType","Message","MessageStringFormat","MESSAGE_SYMBOL","StoredMessageData","Record","StoredMessage","StoredGeneration","StoredMessageV1","MessageContent","Array","FunctionCall","BaseMessageFields","TStructure","TRole","Pick","Standard","OpenAIToolCall","Partial","mergeContent","_mergeStatus","BaseMessage","NonNullable","Symbol","toStringTag","isOpenAIToolCallArray","_mergeDicts","_mergeLists","Content","_mergeObj","T","BaseMessageChunk","MessageFieldWithRole","_isMessageFieldWithRole","BaseMessageLike","isBaseMessage","isBaseMessageChunk"],"sources":["../../src/messages/base.d.ts"],"sourcesContent":["import { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { ContentBlock } from \"./content/index.js\";\nimport { $InferMessageContent, $InferResponseMetadata, MessageStructure, MessageType, Message } from \"./message.js\";\nimport { type MessageStringFormat } from \"./format.js\";\n/** @internal */\ndeclare const MESSAGE_SYMBOL: unique symbol;\nexport interface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n response_metadata?: Record<string, any>;\n id?: string;\n}\nexport interface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\nexport interface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\nexport interface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\nexport type MessageContent = string | Array<ContentBlock>;\nexport interface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n /**\n * The name of the function to call.\n */\n name: string;\n}\nexport type BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = Pick<Message, \"id\" | \"name\"> & {\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\nexport declare function mergeContent(firstContent: MessageContent, secondContent: MessageContent): MessageContent;\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\nexport declare function _mergeStatus(left?: \"success\" | \"error\", right?: \"success\" | \"error\"): \"success\" | \"error\" | undefined;\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\nexport declare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {\n lc_namespace: string[];\n lc_serializable: boolean;\n get lc_aliases(): Record<string, string>;\n readonly [MESSAGE_SYMBOL]: true;\n abstract readonly type: TRole;\n id?: string;\n /** @inheritdoc */\n name?: string;\n content: $InferMessageContent<TStructure, TRole>;\n additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]>;\n response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>[\"response_metadata\"]>;\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType;\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType;\n constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);\n /** Get text content of the message. */\n get text(): string;\n get contentBlocks(): Array<ContentBlock.Standard>;\n toDict(): StoredMessage;\n static lc_name(): string;\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is BaseMessage;\n _updateId(value: string | undefined): void;\n get [Symbol.toStringTag](): any;\n toFormattedString(format?: MessageStringFormat): string;\n}\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\nexport type OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n index?: number;\n};\nexport declare function isOpenAIToolCallArray(value?: unknown): value is OpenAIToolCall[];\nexport declare function _mergeDicts(left?: Record<string, any>, right?: Record<string, any>): Record<string, any>;\nexport declare function _mergeLists<Content extends ContentBlock>(left?: Content[], right?: Content[]): Content[] | undefined;\nexport declare function _mergeObj<T = any>(left: T | undefined, right: T | undefined): T | undefined;\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\nexport declare abstract class BaseMessageChunk<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n static isInstance(obj: unknown): obj is BaseMessageChunk;\n}\nexport type MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\nexport declare function _isMessageFieldWithRole(x: BaseMessageLike): x is MessageFieldWithRole;\nexport type BaseMessageLike = BaseMessage | MessageFieldWithRole | [MessageType, MessageContent] | string\n/**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */\n | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n} & BaseMessageFields & Record<string, unknown>) | SerializedConstructor;\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\nexport declare function isBaseMessage(messageLike?: unknown): messageLike is BaseMessage;\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\nexport declare function isBaseMessageChunk(messageLike?: unknown): messageLike is BaseMessageChunk;\nexport {};\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;cAKcS;AAAAA,UACGC,iBAAAA,CAD0B;EAC1BA,OAAAA,EAAAA,MAAAA;EAUAE,IAAAA,EAAAA,MAAAA,GAAAA,SAAa;EAIbC,IAAAA,EAAAA,MAAAA,GAAAA,SAAgB;EAIhBC,YAAAA,EAAAA,MAAe,GAAA,SAAA;EAKpBC,iBAAc,CAAA,EAlBFJ,MAkBE,CAAA,MAAkBT,EAAAA,GAAAA,CAAAA;EAC3Be;EAaLC,iBAAAA,CAAAA,EA9BYP,MA8BK,CAAAQ,MAAAA,EAAAA,GAAAA,CAAAC;EAAoBf,EAAAA,CAAAA,EAAAA,MAAAA;;AAAmDC,UA3BnFM,aAAAA,CA2BmFN;EAAcA,IAAAA,EAAAA,MAAAA;EAAoBC,IAAAA,EAzB5HG,iBAyB4HH;;AACnGY,UAxBlBN,gBAAAA,CAwBkBM;EAAYC,IAAAA,EAAAA,MAAAA;EAAjCjB,OAAAA,CAAAA,EAtBAS,aAsBAT;;AACMa,UArBHF,eAAAA,CAqBGE;EAMIC,IAAAA,EAAAA,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