{"version":3,"file":"human.cjs","names":["BaseMessage","BaseMessageChunk","mergeContent","_mergeDicts"],"sources":["../../src/messages/human.ts"],"sourcesContent":["import {\n  BaseMessage,\n  BaseMessageChunk,\n  mergeContent,\n  _mergeDicts,\n  type BaseMessageFields,\n} from \"./base.js\";\nimport type { $InferMessageContent, MessageStructure } from \"./message.js\";\nimport { Constructor } from \"./utils.js\";\n\nexport interface HumanMessageFields<\n  TStructure extends MessageStructure = MessageStructure,\n> extends BaseMessageFields<TStructure, \"human\"> {}\n\n/**\n * Represents a human message in a conversation.\n */\nexport class HumanMessage<\n  TStructure extends MessageStructure = MessageStructure,\n> extends BaseMessage<TStructure, \"human\"> {\n  static lc_name() {\n    return \"HumanMessage\";\n  }\n\n  readonly type = \"human\" as const;\n\n  constructor(\n    fields:\n      | $InferMessageContent<TStructure, \"human\">\n      | HumanMessageFields<TStructure>\n  ) {\n    super(fields);\n  }\n\n  static isInstance(obj: unknown): obj is HumanMessage {\n    return super.isInstance(obj) && obj.type === \"human\";\n  }\n}\n\n/**\n * Represents a chunk of a human message, which can be concatenated with\n * other human message chunks.\n */\nexport class HumanMessageChunk<\n  TStructure extends MessageStructure = MessageStructure,\n> extends BaseMessageChunk<TStructure, \"human\"> {\n  static lc_name() {\n    return \"HumanMessageChunk\";\n  }\n\n  readonly type = \"human\" as const;\n\n  constructor(\n    fields:\n      | $InferMessageContent<TStructure, \"human\">\n      | HumanMessageFields<TStructure>\n  ) {\n    super(fields);\n  }\n\n  concat(chunk: HumanMessageChunk<TStructure>) {\n    const Cls = this.constructor as Constructor<this>;\n    return new Cls({\n      content: mergeContent(this.content, chunk.content),\n      additional_kwargs: _mergeDicts(\n        this.additional_kwargs,\n        chunk.additional_kwargs\n      ),\n      response_metadata: _mergeDicts(\n        this.response_metadata,\n        chunk.response_metadata\n      ),\n      id: this.id ?? chunk.id,\n    });\n  }\n\n  static isInstance(obj: unknown): obj is HumanMessageChunk {\n    return super.isInstance(obj) && obj.type === \"human\";\n  }\n}\n\n/**\n * @deprecated Use {@link HumanMessage.isInstance} instead\n */\nexport function isHumanMessage<TStructure extends MessageStructure>(\n  x: BaseMessage\n): x is HumanMessage<TStructure> {\n  return x.getType() === \"human\";\n}\n\n/**\n * @deprecated Use {@link HumanMessageChunk.isInstance} instead\n */\nexport function isHumanMessageChunk<TStructure extends MessageStructure>(\n  x: BaseMessageChunk\n): x is HumanMessageChunk<TStructure> {\n  return x.getType() === \"human\";\n}\n"],"mappings":";;;;;AAiBA,IAAa,eAAb,cAEUA,aAAAA,YAAiC;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAgB;CAEhB,YACE,QAGA;AACA,QAAM,OAAO;;CAGf,OAAO,WAAW,KAAmC;AACnD,SAAO,MAAM,WAAW,IAAI,IAAI,IAAI,SAAS;;;;;;;AAQjD,IAAa,oBAAb,cAEUC,aAAAA,iBAAsC;CAC9C,OAAO,UAAU;AACf,SAAO;;CAGT,OAAgB;CAEhB,YACE,QAGA;AACA,QAAM,OAAO;;CAGf,OAAO,OAAsC;EAC3C,MAAM,MAAM,KAAK;AACjB,SAAO,IAAI,IAAI;GACb,SAASC,aAAAA,aAAa,KAAK,SAAS,MAAM,QAAQ;GAClD,mBAAmBC,aAAAA,YACjB,KAAK,mBACL,MAAM,kBACP;GACD,mBAAmBA,aAAAA,YACjB,KAAK,mBACL,MAAM,kBACP;GACD,IAAI,KAAK,MAAM,MAAM;GACtB,CAAC;;CAGJ,OAAO,WAAW,KAAwC;AACxD,SAAO,MAAM,WAAW,IAAI,IAAI,IAAI,SAAS;;;;;;AAOjD,SAAgB,eACd,GAC+B;AAC/B,QAAO,EAAE,SAAS,KAAK;;;;;AAMzB,SAAgB,oBACd,GACoC;AACpC,QAAO,EAAE,SAAS,KAAK"}