(improvement)(chat) Split chat into three modules: server, api, and core. (#594)

This commit is contained in:
lexluo09
2024-01-04 16:56:49 +08:00
committed by GitHub
parent 0858c13365
commit 023e84c420
337 changed files with 2407 additions and 2715 deletions

View File

@@ -1,28 +1,30 @@
package com.tencent.supersonic.headless.server.listener;
import com.alibaba.fastjson.JSONObject;
import com.tencent.supersonic.common.config.EmbeddingConfig;
import com.tencent.supersonic.common.pojo.DataEvent;
import com.tencent.supersonic.common.pojo.enums.DictWordType;
import com.tencent.supersonic.common.pojo.enums.EventType;
import com.tencent.supersonic.common.util.ComponentFactory;
import com.tencent.supersonic.common.util.embedding.EmbeddingQuery;
import com.tencent.supersonic.common.util.embedding.S2EmbeddingStore;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
@Slf4j
public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
public static final String COLLECTION_NAME = "meta_collection";
@Autowired
private EmbeddingConfig embeddingConfig;
private S2EmbeddingStore s2EmbeddingStore = ComponentFactory.getS2EmbeddingStore();
@@ -55,14 +57,14 @@ public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
} catch (InterruptedException e) {
log.error("", e);
}
s2EmbeddingStore.addCollection(COLLECTION_NAME);
s2EmbeddingStore.addCollection(embeddingConfig.getMetaCollectionName());
if (event.getEventType().equals(EventType.ADD)) {
s2EmbeddingStore.addQuery(COLLECTION_NAME, embeddingQueries);
s2EmbeddingStore.addQuery(embeddingConfig.getMetaCollectionName(), embeddingQueries);
} else if (event.getEventType().equals(EventType.DELETE)) {
s2EmbeddingStore.deleteQuery(COLLECTION_NAME, embeddingQueries);
s2EmbeddingStore.deleteQuery(embeddingConfig.getMetaCollectionName(), embeddingQueries);
} else if (event.getEventType().equals(EventType.UPDATE)) {
s2EmbeddingStore.deleteQuery(COLLECTION_NAME, embeddingQueries);
s2EmbeddingStore.addQuery(COLLECTION_NAME, embeddingQueries);
s2EmbeddingStore.deleteQuery(embeddingConfig.getMetaCollectionName(), embeddingQueries);
s2EmbeddingStore.addQuery(embeddingConfig.getMetaCollectionName(), embeddingQueries);
}
}

View File

@@ -47,7 +47,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, name, description, version, type, created_at, created_by, updated_at, updated_by,
id, name, description, version, type, created_at, created_by, updated_at, updated_by,
admin, viewer
</sql>
<sql id="Blob_Column_List">
@@ -87,7 +87,7 @@
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
@@ -99,16 +99,16 @@
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.headless.server.persistence.dataobject.DatabaseDO">
insert into s2_database (id, name, description,
version, type, created_at,
created_by, updated_at, updated_by,
admin, viewer, config
)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{version,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR},
#{admin,jdbcType=VARCHAR}, #{viewer,jdbcType=VARCHAR}, #{config,jdbcType=LONGVARCHAR}
)
insert into s2_database (id, name, description,
version, type, created_at,
created_by, updated_at, updated_by,
admin, viewer, config
)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{version,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR},
#{admin,jdbcType=VARCHAR}, #{viewer,jdbcType=VARCHAR}, #{config,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.headless.server.persistence.dataobject.DatabaseDO">
insert into s2_database
@@ -237,30 +237,30 @@
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.headless.server.persistence.dataobject.DatabaseDO">
update s2_database
set name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
version = #{version,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
admin = #{admin,jdbcType=VARCHAR},
viewer = #{viewer,jdbcType=VARCHAR},
config = #{config,jdbcType=LONGVARCHAR}
description = #{description,jdbcType=VARCHAR},
version = #{version,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
admin = #{admin,jdbcType=VARCHAR},
viewer = #{viewer,jdbcType=VARCHAR},
config = #{config,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.headless.server.persistence.dataobject.DatabaseDO">
update s2_database
set name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
version = #{version,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
admin = #{admin,jdbcType=VARCHAR},
viewer = #{viewer,jdbcType=VARCHAR}
description = #{description,jdbcType=VARCHAR},
version = #{version,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
admin = #{admin,jdbcType=VARCHAR},
viewer = #{viewer,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.headless.server.persistence.mapper.ModelDOCustomMapper">
<update id="batchUpdateStatus" parameterType="java.util.List">
<foreach collection="list" item="dimension" separator=";">
update s2_model
set
status = #{model.status,jdbcType=INTEGER},
updated_by = #{model.updatedBy,jdbcType=VARCHAR},
updated_at = #{model.updatedAt,jdbcType=TIMESTAMP}
where id = #{model.id,jdbcType=BIGINT}
</foreach>
</update>
</mapper>