# memsix **Repository Path**: ffch/memsix ## Basic Information - **Project Name**: memsix - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-03-19 - **Last Updated**: 2026-03-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![License](http://img.shields.io/:license-apache-blue.svg "2.0")](http://www.apache.org/licenses/LICENSE-2.0.html) [![JDK 17+](https://img.shields.io/badge/JDK-17%2B-orange "JDK 17+")]() [![Maven Central](https://img.shields.io/maven-central/v/cn.pomit/memsix.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22cn.pomit%22%20AND%20a:%22memsix%22) ## Memsix项目简介 Memsix 参考reme实现的长期记忆(Long-Term Memory)SDK,基于 Java 17 实现。 它通过文件存储和向量检索技术,为智能体提供跨会话的持久化记忆能力,让智能体能够记住用户偏好、历史对话事实等关键信息, 从而在对话中表现出更连贯、个性化的行为。 Memsix 实现了 AgentScope 的 LongTermMemory 接口,可以无缝集成到 AgentScope 的智能体工作流中。 ## [Gitee](https://gitee.com/ffch/memsix) ## [Github](https://github.com/ffch/memsix) ## [maven repo](https://repo1.maven.org/maven2/cn/pomit/memsix/0.0.1/) ## [Get Started](https://www.pomit.cn/memsix/) ## 主要功能 - 文件存储模式:将记忆数据持久化到本地文件系统,支持自定义工作目录和工作空间(workspace),方便多用户隔离管理。 - 向量搜索支持:可选配置嵌入模型,将文本转化为向量并存储,实现基于语义的相似记忆检索,提升记忆召回的准确性。 - 集成 AgentScope:提供 MemSixForAgentScopeLongTermMemory 类,直接实现 AgentScope 的 LongTermMemory 接口,可作为智能体的长期记忆组件使用。 - 向量库的支持:筹备中,计划支持多种向量数据库(如 ES、PGVector 等),提供更高效的向量存储和检索能力。 - 独立部署及docker部署:筹备中,计划提供独立部署的服务版本,并提供docker镜像,方便用户在不同环境中使用。 ## 使用说明 jar包已经上传到maven中央仓库。 https://search.maven.org/search?q=memsix ,groupId为cn.pomit。 [使用文档地址](https://www.pomit.cn/memsix) ### maven依赖 ```xml cn.pomit memsix 0.0.1 ``` ### 整合进AgentScope中 配置```MemSixConfig```,交给```MemSixForAgentScopeLongTermMemory```,```MemSixForAgentScopeLongTermMemory```实现了AgentScope的```LongTermMemory```接口: ```java String llmModelName = "qwen3-max-preview"; String llmBaseUrl = "https://xxx"; String llmApiKey = "xxxx"; String embeddingModelName = "Qwen3-Embedding-0.6B"; String embeddingBaseUrl = "https://xxx"; String embeddingApiKey = "xxx"; MemSixConfig memSixConfig = MemSixConfig.fileMode() .workDirectory("./memsix") .workspaceId("meimei_sunday") .chatModelConfig(ChatModelConfig.builder().apiKey(llmApiKey) .baseUrl(llmBaseUrl) .modelName(llmModelName) .build()) .enableVectorSearch(true) .embedModelConfig(EmbedModelConfig.builder() .modelName(embeddingModelName) .baseUrl(embeddingBaseUrl) .apiKey(embeddingApiKey) .build()) .build(); MemSixForAgentScopeLongTermMemory longTermMemory = new MemSixForAgentScopeLongTermMemory(memSixConfig); ``` 以上配置中 - ```fileMode()```会在当前目录下创建一个memsix文件夹(可配置),作为工作目录。支持bm25 + 向量 混合检索。 - ```mysqlMode()```使用jdbcTemplate操作mysql数据库进行全文检索。支持全文检索+ 向量 混合检索。 - ```workspaceId```指定了工作空间id(可用以区分用户) - 聊天模型配置必填。 - 向量搜索配置可选,如果需要使用向量搜索,必须提供向量搜索模型的配置。 **mysql模式**需要表支持,默认表结构: ```sql CREATE TABLE `agent_user_memory` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '记忆内容', `workspace_id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户标识', `tag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '分类标识', `embeddings` text COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '向量', `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '更新时间', PRIMARY KEY (`id`), UNIQUE KEY `agent_user_memory_workspace_id_IDX` (`workspace_id`,`tag`) USING BTREE, FULLTEXT KEY `agent_user_memory_content_IDX` (`content`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ``` 注意: 1. 需要有唯一索引进行表的更新和插入操作,```workspace_id```和```tag```的组合作为唯一索引,确保同一工作空间下相同标签的记忆只能有一条记录。 2. 可以通过自定义summarySqlTemplate和dailySqlTemplate修改为自定义SQL. 3. useOneTableMode为true时,表示summary和daily用同一个表。daily无需额外配置。 **调用方法** 直接放到AgentScope的```longTermMemory```调用链中: ``` .longTermMemory(longTermMemory) ``` 示例: ```java // 注册数据库更新工具 ReActAgent agent = ReActAgent.builder() .name(memSixConfig.getWorkspaceId() + "的长期记忆助理") .sysPrompt("你是有帮助的AI助理。") .model(OpenAIChatModel.builder() .apiKey(llmApiKey) .baseUrl(llmBaseUrl) .generateOptions(GenerateOptions.builder() .temperature(0.7) .build()) .stream(true) .modelName(llmModelName) .build()) .maxIters(10) .longTermMemory(longTermMemory) .build(); ``` ## 版权声明 memsix使用 Apache License 2.0 协议. ## 作者信息 个人网站:https://www.pomit.cn 作者邮箱: pomitcn@163.com/916881512@qq.com ## License Apache License V2