@prexo/ai-chat-sdk
Version:
AI Chat SDK for building AI chat applications with Context and History
37 lines (33 loc) • 1 kB
text/typescript
import { BaseMessageHistory } from './types.cjs';
import { Redis, RedisConfigNodejs } from '@upstash/redis';
import { Message } from 'ai';
import '@upstash/vector';
type GetHistoryClientParams = {
redis?: {
url: string;
token: string;
};
};
declare const getHistoryClient: (params?: GetHistoryClientParams) => BaseMessageHistory | undefined;
type RedisHistoryConfig = {
config?: RedisConfigNodejs;
client?: Redis;
};
declare class InRedisHistory implements BaseMessageHistory {
client: Redis;
constructor(config: RedisHistoryConfig);
addMessage(params: {
message: Message;
sessionId: string;
sessionTTL?: number;
}): Promise<void>;
deleteMessages({ sessionId }: {
sessionId: string;
}): Promise<void>;
getMessages({ sessionId, amount, startIndex, }: {
sessionId: string;
amount?: number;
startIndex?: number;
}): Promise<Message[]>;
}
export { InRedisHistory, getHistoryClient };