@langchain/core
Version:
Core LangChain.js abstractions and schemas
101 lines (100 loc) • 2.82 kB
TypeScript
import { MessageOutputVersion } from "./message.js";
//#region src/messages/metadata.d.ts
type ResponseMetadata = {
model_provider?: string;
model_name?: string;
output_version?: MessageOutputVersion;
[key: string]: unknown;
};
declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;
type ModalitiesTokenDetails = {
/**
* Text tokens.
* Does not need to be reported, but some models will do so.
*/
text?: number;
/**
* Image (non-video) tokens.
*/
image?: number;
/**
* Audio tokens.
*/
audio?: number;
/**
* Video tokens.
*/
video?: number;
/**
* Document tokens.
* e.g. PDF
*/
document?: number;
};
/**
* Breakdown of input token counts.
*
* Does not *need* to sum to full input token count. Does *not* need to have all keys.
*/
type InputTokenDetails = ModalitiesTokenDetails & {
/**
* Input tokens that were cached and there was a cache hit.
*
* Since there was a cache hit, the tokens were read from the cache.
* More precisely, the model state given these tokens was read from the cache.
*/
cache_read?: number;
/**
* Input tokens that were cached and there was a cache miss.
*
* Since there was a cache miss, the cache was created from these tokens.
*/
cache_creation?: number;
};
/**
* Breakdown of output token counts.
*
* Does *not* need to sum to full output token count. Does *not* need to have all keys.
*/
type OutputTokenDetails = ModalitiesTokenDetails & {
/**
* Reasoning output tokens.
*
* Tokens generated by the model in a chain of thought process (i.e. by
* OpenAI's o1 models) that are not returned as part of model output.
*/
reasoning?: number;
};
/**
* Usage metadata for a message, such as token counts.
*/
type UsageMetadata = {
/**
* Count of input (or prompt) tokens. Sum of all input token types.
*/
input_tokens: number;
/**
* Count of output (or completion) tokens. Sum of all output token types.
*/
output_tokens: number;
/**
* Total token count. Sum of input_tokens + output_tokens.
*/
total_tokens: number;
/**
* Breakdown of input token counts.
*
* Does *not* need to sum to full input token count. Does *not* need to have all keys.
*/
input_token_details?: InputTokenDetails;
/**
* Breakdown of output token counts.
*
* Does *not* need to sum to full output token count. Does *not* need to have all keys.
*/
output_token_details?: OutputTokenDetails;
};
declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;
//#endregion
export { InputTokenDetails, ModalitiesTokenDetails, OutputTokenDetails, ResponseMetadata, UsageMetadata, mergeResponseMetadata, mergeUsageMetadata };
//# sourceMappingURL=metadata.d.ts.map