UNPKG

@langchain/community

Version:
1 lines • 3.5 kB
{"version":3,"file":"firestore.d.cts","names":["AppOptions","BaseListChatMessageHistory","BaseMessage","FirestoreDBChatMessageHistory","FirestoreChatMessageHistory","collections","docs","sessionId","userId","appIdx","config","Promise"],"sources":["../../../src/stores/message/firestore.d.ts"],"sourcesContent":["import type { AppOptions } from \"firebase-admin\";\nimport { BaseListChatMessageHistory } from \"@langchain/core/chat_history\";\nimport { BaseMessage } from \"@langchain/core/messages\";\n/**\n * Interface for FirestoreDBChatMessageHistory. It includes the collection\n * name, session ID, user ID, and optionally, the app index and\n * configuration for the Firebase app.\n */\nexport interface FirestoreDBChatMessageHistory {\n /**\n * An array of collection names, should match the length of `docs` field.\n * @TODO make required variable in 0.2\n */\n collections?: string[];\n /**\n * An array of doc names, should match the length of `collections` field,\n * or undefined if the collections field has a length of 1. In this case,\n * it will default to use `sessionId` as the doc name.\n * @TODO make required variable in 0.2\n */\n docs?: string[];\n sessionId: string;\n userId: string;\n appIdx?: number;\n config?: AppOptions;\n}\n/**\n * Class for managing chat message history using Google's Firestore as a\n * storage backend. Extends the BaseListChatMessageHistory class.\n * @example\n * ```typescript\n * const chatHistory = new FirestoreChatMessageHistory({\n * collectionName: \"langchain\",\n * sessionId: \"lc-example\",\n * userId: \"a@example.com\",\n * config: { projectId: \"your-project-id\" },\n * });\n *\n * const chain = new ConversationChain({\n * llm: new ChatOpenAI({ model: \"gpt-4o-mini\" }),\n * memory: new BufferMemory({ chatHistory }),\n * });\n *\n * const response = await chain.invoke({\n * input: \"What did I just say my name was?\",\n * });\n * console.log({ response });\n * ```\n */\nexport declare class FirestoreChatMessageHistory extends BaseListChatMessageHistory {\n lc_namespace: string[];\n private collections;\n private docs;\n private sessionId;\n private userId;\n private appIdx;\n private config;\n private firestoreClient;\n private document;\n constructor({ collections, docs, sessionId, userId, appIdx, config }: FirestoreDBChatMessageHistory);\n private ensureFirestore;\n /**\n * Method to retrieve all messages from the Firestore collection\n * associated with the current session. Returns an array of BaseMessage\n * objects.\n * @returns Array of stored messages\n */\n getMessages(): Promise<BaseMessage[]>;\n /**\n * Method to add a new message to the Firestore collection. The message is\n * passed as a BaseMessage object.\n * @param message The message to be added as a BaseMessage object.\n */\n addMessage(message: BaseMessage): Promise<void>;\n private upsertMessage;\n /**\n * Method to delete all messages from the Firestore collection associated\n * with the current session.\n */\n clear(): Promise<void>;\n}\n//# sourceMappingURL=firestore.d.ts.map"],"mappings":";;;;;;;;AAQA;AAyCA;;AAU+BM,UAnDdH,6BAAAA,CAmDcG;EAAMC;;;;EAAqCJ,WAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAQ/CD;;;;;;EAlBwD,IAAA,CAAA,EAAA,MAAA,EAAA;;;;WAzBtEF;;;;;;;;;;;;;;;;;;;;;;;;;cAyBQI,2BAAAA,SAAoCH,0BAAAA;;;;;;;;;;;;;;;;;KAUiBE;;;;;;;;iBAQvDQ,QAAQT;;;;;;sBAMHA,cAAcS;;;;;;WAMzBA"}