UNPKG

@langchain/core

Version:
1 lines 3.8 kB
{"version":3,"file":"index.cjs","names":["KNOWN_BLOCK_TYPES","KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;;AAaA,MAAaA,sBAAoB;CAC/B;CACA;CACA,GAAGC;CACH,GAAGC;AACJ"}