import { CosmosClient } from "@azure/cosmos"; import { TokenCredential } from "@azure/identity"; import { BaseListChatMessageHistory } from "@langchain/core/chat_history"; import { BaseMessage } from "@langchain/core/messages"; //#region src/chat_histories/nosql.d.ts /** * Lightweight type for listing chat sessions. */ type ChatSession = { id: string; context: Record; }; /** * Type for the input to the `AzureCosmosDBNoSQLChatMessageHistory` constructor. */ interface AzureCosmosDBNoSQLChatMessageHistoryInput { sessionId: string; userId?: string; client?: CosmosClient; connectionString?: string; endpoint?: string; databaseName?: string; containerName?: string; credentials?: TokenCredential; ttl?: number; } /** * Class for storing chat message history with Cosmos DB NoSQL. It extends the * BaseListChatMessageHistory class and provides methods to get, add, and * clear messages. * * @example * ```typescript * const model = new ChatOpenAI({ * model: "gpt-3.5-turbo", * temperature: 0, * }); * const prompt = ChatPromptTemplate.fromMessages([ * [ * "system", * "You are a helpful assistant. Answer all questions to the best of your ability.", * ], * new MessagesPlaceholder("chat_history"), * ["human", "{input}"], * ]); * * const chain = prompt.pipe(model).pipe(new StringOutputParser()); * const chainWithHistory = new RunnableWithMessageHistory({ * runnable: chain, * inputMessagesKey: "input", * historyMessagesKey: "chat_history", * getMessageHistory: async (sessionId) => { * const chatHistory = new AzureCosmsosDBNoSQLChatMessageHistory({ * sessionId: sessionId, * userId: "user-id", * databaseName: "DATABASE_NAME", * containerName: "CONTAINER_NAME", * }) * return chatHistory; * }, * }); * await chainWithHistory.invoke( * { input: "What did I just say my name was?" }, * { configurable: { sessionId: "session-id" } } * ); * ``` */ declare class AzureCosmsosDBNoSQLChatMessageHistory extends BaseListChatMessageHistory { lc_namespace: string[]; private container; private sessionId; private databaseName; private containerName; private client; private userId; private ttl; private messageList; private initPromise?; private context; constructor(chatHistoryInput: AzureCosmosDBNoSQLChatMessageHistoryInput); private initializeClient; private initializeContainer; getMessages(): Promise; addMessage(message: BaseMessage): Promise; addMessages(messages: BaseMessage[]): Promise; clear(): Promise; clearAllSessions(): Promise; getAllSessions(): Promise; getContext(): Promise>; setContext(context: Record): Promise; } //#endregion export { AzureCosmosDBNoSQLChatMessageHistoryInput, AzureCosmsosDBNoSQLChatMessageHistory, ChatSession }; //# sourceMappingURL=nosql.d.cts.map