@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 5.77 kB
Source Map (JSON)
{"version":3,"file":"mem0.d.cts","names":["MemoryClient","Memory","MemoryOptions","SearchOptions","InputValues","OutputValues","MemoryVariables","BaseMessage","HumanMessage","BaseChatMemory","BaseChatMemoryInput","mem0MemoryContextToSystemPrompt","condenseMem0MemoryIntoHumanMessage","_langchain_core_messages0","MessageToolSet","MessageStructure","mem0MemoryToMessages","MessageType","ClientOptions","Mem0MemoryInput","Mem0Memory","InstanceType","Promise"],"sources":["../../src/memory/mem0.d.ts"],"sourcesContent":["import { MemoryClient } from \"mem0ai\";\nimport type { Memory, MemoryOptions, SearchOptions } from \"mem0ai\";\nimport { InputValues, OutputValues, MemoryVariables } from \"@langchain/core/memory\";\nimport { BaseMessage, HumanMessage } from \"@langchain/core/messages\";\nimport { BaseChatMemory, BaseChatMemoryInput } from \"./chat_memory.js\";\n/**\n * Extracts and formats memory content into a system prompt\n * @param memory Array of Memory objects from mem0ai\n * @returns Formatted system prompt string\n */\nexport declare const mem0MemoryContextToSystemPrompt: (memory: Memory[]) => string;\n/**\n * Condenses memory content into a single HumanMessage with context\n * @param memory Array of Memory objects from mem0ai\n * @returns HumanMessage containing formatted memory context\n */\nexport declare const condenseMem0MemoryIntoHumanMessage: (memory: Memory[]) => HumanMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>>;\n/**\n * Converts Mem0 memories to a list of BaseMessages\n * @param memories Array of Memory objects from mem0ai\n * @returns Array of BaseMessage objects\n */\nexport declare const mem0MemoryToMessages: (memories: Memory[]) => BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[];\n/**\n * Interface defining the structure of the input data for the Mem0Client\n */\nexport interface ClientOptions {\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n organizationId?: string;\n projectId?: string;\n}\n/**\n * Interface defining the structure of the input data for the Mem0Memory\n * class. It includes properties like memoryKey, sessionId, and apiKey.\n */\nexport interface Mem0MemoryInput extends BaseChatMemoryInput {\n sessionId: string;\n apiKey: string;\n humanPrefix?: string;\n aiPrefix?: string;\n memoryOptions?: MemoryOptions | SearchOptions;\n mem0Options?: ClientOptions;\n separateMessages?: boolean;\n}\n/**\n * Class used to manage the memory of a chat session using the Mem0 service.\n * It handles loading and saving chat history, and provides methods to format\n * the memory content for use in chat models.\n *\n * @example\n * ```typescript\n * const memory = new Mem0Memory({\n * sessionId: \"user123\" // or use user_id inside of memoryOptions (recommended),\n * apiKey: \"your-api-key\",\n * memoryOptions: {\n * user_id: \"user123\",\n * run_id: \"run123\"\n * },\n * });\n *\n * // Use with a chat model\n * const model = new ChatOpenAI({\n * model: \"gpt-3.5-turbo\",\n * temperature: 0,\n * });\n *\n * const chain = new ConversationChain({ llm: model, memory });\n * ```\n */\nexport declare class Mem0Memory extends BaseChatMemory implements Mem0MemoryInput {\n memoryKey: string;\n apiKey: string;\n sessionId: string;\n humanPrefix: string;\n aiPrefix: string;\n mem0Client: InstanceType<typeof MemoryClient>;\n memoryOptions: MemoryOptions | SearchOptions;\n mem0Options: ClientOptions;\n separateMessages?: boolean;\n constructor(fields: Mem0MemoryInput);\n get memoryKeys(): string[];\n /**\n * Retrieves memories from the Mem0 service and formats them for use\n * @param values Input values containing optional search query\n * @returns Promise resolving to formatted memory variables\n */\n loadMemoryVariables(values: InputValues): Promise<MemoryVariables>;\n /**\n * Saves the current conversation context to the Mem0 service\n * @param inputValues Input messages to be saved\n * @param outputValues Output messages to be saved\n * @returns Promise resolving when the context has been saved\n */\n saveContext(inputValues: InputValues, outputValues: OutputValues): Promise<void>;\n /**\n * Clears all memories for the current session\n * @returns Promise resolving when memories have been cleared\n */\n clear(): Promise<void>;\n}\n//# sourceMappingURL=mem0.d.ts.map"],"mappings":";;;;;;;;;;AAUA;AAMA;;AAAwEa,cANnDF,+BAM8JG,EAAAA,CAAAA,MAAAA,EANpHb,MAMoHa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