[improvement][launcher]Refactor unit tests and demo data.

[improvement][launcher]Refactor unit tests and demo data.

[improvement][launcher]Refactor unit tests and demo data.

[improvement][launcher]Refactor unit tests and demo data.
This commit is contained in:
jerryjzhang
2024-12-01 16:23:05 +08:00
parent 1c73453c5f
commit 0f1c50167d
84 changed files with 2097 additions and 7421 deletions

View File

@@ -1,5 +1,8 @@
package com.tencent.supersonic.chat.server.persistence.dataobject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.ToString;
@@ -7,9 +10,10 @@ import java.util.Date;
@Data
@ToString
@TableName("s2_chat_config")
public class ChatConfigDO {
/** database auto-increment primary key */
@TableId(type = IdType.AUTO)
private Long id;
private Long modelId;

View File

@@ -1,15 +1,21 @@
package com.tencent.supersonic.chat.server.persistence.dataobject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.Instant;
@Data
@TableName("s2_chat_context")
public class ChatContextDO implements Serializable {
@TableId
private Integer chatId;
private Instant modifiedAt;
@TableField("query_user")
private String user;
private String queryText;
private String semanticParse;

View File

@@ -1,5 +1,6 @@
package com.tencent.supersonic.chat.server.persistence.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tencent.supersonic.chat.server.config.ChatConfigFilterInternal;
import com.tencent.supersonic.chat.server.persistence.dataobject.ChatConfigDO;
import org.apache.ibatis.annotations.Mapper;
@@ -7,11 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ChatConfigMapper {
Long addConfig(ChatConfigDO chaConfigPO);
Long editConfig(ChatConfigDO chaConfigPO);
public interface ChatConfigMapper extends BaseMapper<ChatConfigDO> {
List<ChatConfigDO> search(ChatConfigFilterInternal filterInternal);

View File

@@ -1,14 +1,11 @@
package com.tencent.supersonic.chat.server.persistence.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tencent.supersonic.chat.server.persistence.dataobject.ChatContextDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ChatContextMapper {
public interface ChatContextMapper extends BaseMapper<ChatContextDO> {
ChatContextDO getContextByChatId(Integer chatId);
int updateContext(ChatContextDO contextDO);
int addContext(ChatContextDO contextDO);
}

View File

@@ -32,15 +32,15 @@ public class ChatConfigRepositoryImpl implements ChatConfigRepository {
@Override
public Long createConfig(ChatConfig chaConfig) {
ChatConfigDO chaConfigDO = chatConfigHelper.chatConfig2DO(chaConfig);
chatConfigMapper.addConfig(chaConfigDO);
chatConfigMapper.insert(chaConfigDO);
return chaConfigDO.getId();
}
@Override
public Long updateConfig(ChatConfig chaConfig) {
ChatConfigDO chaConfigDO = chatConfigHelper.chatConfig2DO(chaConfig);
return chatConfigMapper.editConfig(chaConfigDO);
chatConfigMapper.updateById(chaConfigDO);
return chaConfigDO.getId();
}
@Override

View File

@@ -35,12 +35,7 @@ public class ChatContextRepositoryImpl implements ChatContextRepository {
@Override
public void updateContext(ChatContext chatCtx) {
ChatContextDO context = cast(chatCtx);
if (chatContextMapper.getContextByChatId(chatCtx.getChatId()) == null) {
chatContextMapper.addContext(context);
} else {
chatContextMapper.updateContext(context);
}
chatContextMapper.insertOrUpdate(cast(chatCtx));
}
private ChatContext cast(ChatContextDO contextDO) {

View File

@@ -20,54 +20,6 @@
<result column="updated_at" property="updatedAt"/>
</resultMap>
<insert id="addConfig"
parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatConfigDO"
useGeneratedKeys="true" keyProperty="id">
insert into s2_chat_config
(
model_id, `chat_detail_config`, chat_agg_config, recommended_questions, status, llm_examples, created_by, updated_by, created_at, updated_at
)
values
(
#{modelId}, #{chatDetailConfig}, #{chatAggConfig}, #{recommendedQuestions}, #{status}, #{llmExamples}, #{createdBy}, #{updatedBy}, #{createdAt}, #{updatedAt}
)
</insert>
<update id="editConfig">
update s2_chat_config
<set>
`updated_at` = #{updatedAt} ,
<if test="chatDetailConfig != null and chatDetailConfig != ''">
`chat_detail_config` = #{chatDetailConfig} ,
</if>
<if test="chatAggConfig != null and chatAggConfig != ''">
chat_agg_config = #{chatAggConfig} ,
</if>
<if test="recommendedQuestions != null and recommendedQuestions != ''">
recommended_questions = #{recommendedQuestions} ,
</if>
<if test="status != null and status != ''">
status = #{status} ,
</if>
<if test="updatedBy != null and updatedBy != ''">
updated_by = #{updatedBy} ,
</if>
<if test="llmExamples != null and llmExamples != ''">
llm_examples = #{llmExamples} ,
</if>
</set>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
<if test="modelId != null and modelId != ''">
and model_id = #{modelId}
</if>
</where>
</update>
<select id="search" resultMap="chaConfigDO">
select *
from s2_chat_config

View File

@@ -20,11 +20,4 @@
from s2_chat_context where chat_id=#{chatId} limit 1
</select>
<insert id="addContext" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatContextDO" >
insert into s2_chat_context (chat_id,user,query_text,semantic_parse) values (#{chatId}, #{user},#{queryText}, #{semanticParse})
</insert>
<update id="updateContext">
update s2_chat_context set query_text=#{queryText},semantic_parse=#{semanticParse} where chat_id=#{chatId}
</update>
</mapper>