UNPKG

@langchain/core

Version:
59 lines (57 loc) 1.53 kB
import { BaseMessage, BaseMessageChunk, _mergeDicts, mergeContent } from "./base.js"; //#region src/messages/system.ts /** * Represents a system message in a conversation. */ var SystemMessage = class extends BaseMessage { static lc_name() { return "SystemMessage"; } type = "system"; constructor(fields) { super(fields); } static isInstance(obj) { return super.isInstance(obj) && obj.type === "system"; } }; /** * Represents a chunk of a system message, which can be concatenated with * other system message chunks. */ var SystemMessageChunk = class extends BaseMessageChunk { static lc_name() { return "SystemMessageChunk"; } type = "system"; constructor(fields) { super(fields); } concat(chunk) { const Cls = this.constructor; return new Cls({ content: mergeContent(this.content, chunk.content), additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs), response_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata), id: this.id ?? chunk.id }); } static isInstance(obj) { return super.isInstance(obj) && obj.type === "system"; } }; /** * @deprecated Use {@link SystemMessage.isInstance} instead */ function isSystemMessage(x) { return x._getType() === "system"; } /** * @deprecated Use {@link SystemMessageChunk.isInstance} instead */ function isSystemMessageChunk(x) { return x._getType() === "system"; } //#endregion export { SystemMessage, SystemMessageChunk, isSystemMessage, isSystemMessageChunk }; //# sourceMappingURL=system.js.map