Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
62a30d4
记忆功能支持
970263611 Aug 1, 2025
ed5bf40
Merge branch 'feat-jmanus-suppotMemory' of https://github.com/9702636…
970263611 Aug 4, 2025
72c8b87
优化
970263611 Aug 4, 2025
3c7e363
添加内存支持
970263611 Aug 4, 2025
d33a18f
添加页面选择记忆能力,待优化前后端交互数据
970263611 Aug 5, 2025
bc9a0db
Merge branch 'feat-jmanus-suppotMemory' of https://github.com/9702636…
970263611 Aug 6, 2025
5395e74
去除无效依赖
970263611 Aug 6, 2025
ed30958
排除冲突依赖
970263611 Aug 6, 2025
7855d1f
优化页面展示
970263611 Aug 6, 2025
7d2cf45
优化记忆能力
970263611 Aug 6, 2025
692e91a
添加h2数据库内存支持
970263611 Aug 6, 2025
4a7e916
国际化支持
970263611 Aug 6, 2025
491b501
添加注释
970263611 Aug 6, 2025
af81363
优化页面图标
970263611 Aug 6, 2025
64b1531
优化页面样式
970263611 Aug 7, 2025
a855650
去除中文
970263611 Aug 7, 2025
f6eeff5
格式化代码
970263611 Aug 7, 2025
174f24d
文件尾添加空行
970263611 Aug 7, 2025
136c92c
去除无效依赖
970263611 Aug 7, 2025
24de266
优化页面展示
970263611 Aug 7, 2025
9ac17e7
调整页面样式,优化功能
970263611 Aug 7, 2025
e2a8956
格式化和添加协议
970263611 Aug 7, 2025
765d827
去除无效依赖
970263611 Aug 7, 2025
3f61924
优化记忆内容
970263611 Aug 8, 2025
e03633c
优化前端写法
970263611 Aug 8, 2025
5d49600
优化参数写法
970263611 Aug 8, 2025
6d529cc
前端编译后提交
970263611 Aug 8, 2025
ad30fbb
Merge branch 'main' into feat-jmanus-suppotMemory
970263611 Aug 8, 2025
904c15c
记忆id构建从前端改为后端,优化重复任务会多次存储记忆问题
970263611 Aug 9, 2025
7355ce3
重新打包前端页面
970263611 Aug 9, 2025
8dcddaa
优化home页对话失败问题
970263611 Aug 9, 2025
520526f
重新编译前端页面
970263611 Aug 9, 2025
774dea1
优化页面显示
970263611 Aug 9, 2025
d16ed4d
优化页面样式
970263611 Aug 9, 2025
92a2bc2
优化样式,去除无用代码
970263611 Aug 9, 2025
ec1787f
merge
970263611 Aug 9, 2025
e4d78a3
merge and build
970263611 Aug 9, 2025
bf3e92b
格式化代码
970263611 Aug 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2024-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.cloud.ai.autoconfigure.memory;

import com.alibaba.cloud.ai.memory.jdbc.H2ChatMemoryRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;

/**
* Auto-configuration for h2 chat memory repository.
*/
@AutoConfiguration(after = JdbcTemplateAutoConfiguration.class)
@ConditionalOnClass({ H2ChatMemoryRepository.class, JdbcTemplate.class })
@ConditionalOnProperty(prefix = "spring.ai.memory.h2", name = "enabled", havingValue = "true", matchIfMissing = false)
@EnableConfigurationProperties(H2ChatMemoryProperties.class)
public class H2ChatMemoryAutoConfiguration {

private static final Logger logger = LoggerFactory.getLogger(H2ChatMemoryAutoConfiguration.class);

@Bean
@Qualifier("h2ChatMemoryRepository")
@ConditionalOnMissingBean(name = "h2ChatMemoryRepository")
H2ChatMemoryRepository h2ChatMemoryRepository(JdbcTemplate jdbcTemplate) {
logger.info("Configuring H2 chat memory repository");
return H2ChatMemoryRepository.h2Builder().jdbcTemplate(jdbcTemplate).build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2024-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.cloud.ai.autoconfigure.memory;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
* Configuration properties for H2 chat memory repository.
*/
@ConfigurationProperties(H2ChatMemoryProperties.CONFIG_PREFIX)
public class H2ChatMemoryProperties {

public static final String CONFIG_PREFIX = "spring.ai.memory.h2";

private boolean initializeSchema = true;

public boolean isInitializeSchema() {
return this.initializeSchema;
}

public void setInitializeSchema(boolean initializeSchema) {
this.initializeSchema = initializeSchema;
}

/**
* JDBC URL of the database.
*/
private String jdbcUrl;

/**
* Database username.
*/
private String username;

/**
* Database password.
*/
private String password;

/**
* Fully qualified name of the JDBC driver class.
*/
private String driverClassName = "org.h2.Driver";

/**
* Whether to enable custom datasource configuration.
*/
private boolean enabled = false;

public String getJdbcUrl() {
return jdbcUrl;
}

public void setJdbcUrl(String jdbcUrl) {
this.jdbcUrl = jdbcUrl;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getDriverClassName() {
return driverClassName;
}

public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2024-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.ai.memory.jdbc;

import org.springframework.jdbc.core.JdbcTemplate;

/**
* auth: dahua
*/
public class H2ChatMemoryRepository extends JdbcChatMemoryRepository {

// H2 specific query statements
private static final String H2_QUERY_ADD = "INSERT INTO ai_chat_memory (conversation_id, content, type, timestamp) VALUES (?, ?, ?, ?)";

private static final String H2_QUERY_GET = "SELECT content, type FROM ai_chat_memory WHERE conversation_id = ? ORDER BY timestamp";

private H2ChatMemoryRepository(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}

public static H2ChatMemoryRepository.H2Builder h2Builder() {
return new H2ChatMemoryRepository.H2Builder();
}

public static class H2Builder {

private JdbcTemplate jdbcTemplate;

public H2ChatMemoryRepository.H2Builder jdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
return this;
}

public H2ChatMemoryRepository build() {
return new H2ChatMemoryRepository(this.jdbcTemplate);
}

}

@Override
protected String hasTableSql(String tableName) {
return String.format("SELECT table_name FROM information_schema.tables WHERE table_name = '%s'", tableName);
}

@Override
protected String createTableSql(String tableName) {
return String.format(
"CREATE TABLE %s (id BIGINT AUTO_INCREMENT PRIMARY KEY, "
+ "conversation_id VARCHAR(256) NOT NULL, content LONGTEXT NOT NULL, "
+ "type VARCHAR(100) NOT NULL, timestamp TIMESTAMP NOT NULL, "
+ "CONSTRAINT chk_message_type CHECK (type IN ('USER', 'ASSISTANT', 'SYSTEM', 'TOOL')))",
tableName);
}

@Override
protected String getAddSql() {
return H2_QUERY_ADD;
}

@Override
protected String getGetSql() {
return H2_QUERY_GET;
}

}
Loading
Loading