generator-begcode
Version:
Spring Boot + Angular/React/Vue in one handy generator
42 lines (41 loc) • 1.58 kB
TypeScript
import { ChatCompletionMessageParam } from 'openai/resources/index.js';
import { Tokenizer } from './index.js';
import { FunctionDefinition } from '../index.js';
type OmitUnion<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
export type ChatMessage = OmitUnion<ChatCompletionMessageParam, 'content'> & {
content: string | null;
};
export type ChatLogType = 'persistent' | 'temporary';
export interface ChatLog {
tokens: number;
msgs: ChatMessage[];
}
export interface ChatFunctions {
tokens: number;
definitions: FunctionDefinition[];
}
export declare class ChatLogs {
private _logs;
private _tokensPerMsg;
private _functions;
constructor(logs?: Record<ChatLogType, ChatLog>, tokensPerMsg?: Record<ChatLogType, number[]>, functions?: ChatFunctions);
get tokens(): number;
get messages(): ChatMessage[];
get(type: ChatLogType): ChatLog;
getMsg(type: ChatLogType, index: number): ChatMessage | undefined;
getMsgTokens(type: ChatLogType, index: number): number;
add(type: ChatLogType, msgs: ChatMessage[], tokens: number[]): void;
insert(type: ChatLogType, msgs: ChatMessage[], tokens: number[], index: number): void;
addFunction(fn: FunctionDefinition, tokens: number): void;
clone(): ChatLogs;
toString(): string;
toJSON(): {
msgs: Record<ChatLogType, ChatLog>;
functions: {
tokens: number;
names: string[];
};
};
static from(persistentMsgs: ChatMessage[], temporaryMsgs: ChatMessage[], tokenizer: Tokenizer): ChatLogs;
}
export {};