Skip to content

Type Alias: LLamaChatContextShiftOptions

ts
type LLamaChatContextShiftOptions = {
  size?:   | number
     | (sequence: LlamaContextSequence) => 
     | number
     | Promise<number>;
  strategy?:   | "eraseFirstResponseAndKeepFirstSystem"
     | (options: {
     chatHistory: readonly ChatHistoryItem[];
     maxTokensCount: number;
     tokenizer: Tokenizer;
     chatWrapper: ChatWrapper;
     lastShiftMetadata?: object | null;
   }) => 
     | {
     chatHistory: ChatHistoryItem[];
     metadata?: object | null;
   }
     | Promise<{
     chatHistory: ChatHistoryItem[];
     metadata?: object | null;
   }>;
  lastEvaluationMetadata?: object | null;
};

Defined in: evaluator/LlamaChat/LlamaChat.ts:380

Properties

size?

ts
optional size: 
  | number
  | (sequence: LlamaContextSequence) => 
  | number
  | Promise<number>;

Defined in: evaluator/LlamaChat/LlamaChat.ts:385

The number of tokens to delete from the context window to make space for new ones. Defaults to 10% of the context size.


strategy?

ts
optional strategy: 
  | "eraseFirstResponseAndKeepFirstSystem"
  | (options: {
  chatHistory: readonly ChatHistoryItem[];
  maxTokensCount: number;
  tokenizer: Tokenizer;
  chatWrapper: ChatWrapper;
  lastShiftMetadata?: object | null;
}) => 
  | {
  chatHistory: ChatHistoryItem[];
  metadata?: object | null;
}
  | Promise<{
  chatHistory: ChatHistoryItem[];
  metadata?: object | null;
}>;

Defined in: evaluator/LlamaChat/LlamaChat.ts:392

The strategy to use when deleting tokens from the context window.

Defaults to "eraseFirstResponseAndKeepFirstSystem".


lastEvaluationMetadata?

ts
optional lastEvaluationMetadata: object | null;

Defined in: evaluator/LlamaChat/LlamaChat.ts:419

The contextShiftMetadata returned from the last evaluation. This is an optimization to utilize the existing context state better when possible.