@langchain/core
Version:
Core LangChain.js abstractions and schemas
139 lines • 3.99 kB
text/typescript
import { BaseContentBlock } from "./base.cjs";
import { Tools } from "./tools.cjs";
import { Multimodal } from "./multimodal.cjs";
import { Data } from "./data.cjs";
import { DeepPartial } from "../../types/type-utils.cjs";
export interface ContentBlock extends BaseContentBlock {}
export type PartialContentBlock<T extends ContentBlock = ContentBlock> = {
readonly type: T["type"];
} & DeepPartial<Exclude<T, "type">>;
export declare const KNOWN_BLOCK_TYPES: string[];
export declare namespace ContentBlock {
/**
* Annotation for citing data from a document.
*/
export interface Citation {
/**
* Type of the content block
*/
readonly type: "citation";
/**
* Source type for the citation.
*/
source?: string;
/**
* URL of the document source
*/
url?: string;
/**
* Source document title.
*
* For example, the page title for a web page or the title of a paper.
*/
title?: string;
/**
* Start index of the **response text** for which the annotation applies.
*
* @see {Text}
*/
startIndex?: number;
/**
* End index of the **response text** for which the annotation applies.
*
* @see {Text}
*/
endIndex?: number;
/**
* Excerpt of source text being cited.
*/
citedText?: string;
}
/**
* Text output from a LLM.
*
* This typically represents the main text content of a message, such as the response
* from a language model or the text of a user message.
*/
export interface Text extends ContentBlock {
/**
* Type of the content block
*/
readonly type: "text";
/**
* Block text.
*/
text: string;
/**
* Index of block in aggregate response. Used during streaming.
*/
index?: string | number;
/**
* Citations and other annotations.
*/
annotations?: Array<Citation | BaseContentBlock>;
}
/**
* Reasoning output from a LLM.
*/
export interface Reasoning extends ContentBlock {
/**
* Type of the content block
*/
readonly type: "reasoning";
/**
* Reasoning text.
*
* Either the thought summary or the raw reasoning text itself.
* This is often parsed from `<think>` tags in the model's response.
*/
reasoning: string;
/**
* Index of block in aggregate response. Used during streaming.
*/
index?: string | number;
}
/**
* An explicit refusal reported by the model provider.
*
* Providers report refusals, such as safety-policy refusals, as successful
* responses. This block marks them so callers can tell a refusal apart from
* an empty or unparsable answer. Refusals the model writes as ordinary text
* are not detected.
*/
export interface Refusal extends ContentBlock {
/**
* Type of the content block
*/
readonly type: "refusal";
/**
* The refusal message, or an empty string if the provider sent none.
*/
refusal: string;
/**
* Additional provider-specific data, such as Anthropic's refusal `category`.
*/
extras?: Record<string, unknown>;
}
/**
* Provider-specific content block.
*
* This is used to represent content blocks that are not part of the standard LangChain content model.
* If a provider's non-standard output includes reasoning and tool calls, it should be
* the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.
*/
export interface NonStandard<TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {
/**
* Type of the content block
*/
type: "non_standard";
/**
* Provider-specific data
*/
value: TValue;
}
export { Tools };
export { Multimodal };
export { Data };
export type Standard = Text | Reasoning | Refusal | NonStandard | Tools.Standard | Multimodal.Standard;
}
//# sourceMappingURL=index.d.cts.map