Commit be0c81458d7d0e9a11fec8a5c1ba615fb61ed261
1 parent
bff0ad65
增加对话类型,new还是继续
Showing
3 changed files
with
102 additions
and
0 deletions
yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatConversationTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.enums; | |
| 2 | + | |
| 3 | +import lombok.AllArgsConstructor; | |
| 4 | +import lombok.Getter; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 对话类型 | |
| 8 | + * 创建对话、继续对话 | |
| 9 | + * | |
| 10 | + * @author fansili | |
| 11 | + * @time 2024/4/14 18:15 | |
| 12 | + * @since 1.0 | |
| 13 | + */ | |
| 14 | +@AllArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum ChatConversationTypeEnum { | |
| 17 | + | |
| 18 | + NEW("new", "新建对话"), | |
| 19 | + CONTINUE("continue", "继续对话"), | |
| 20 | + | |
| 21 | + ; | |
| 22 | + | |
| 23 | + private String type; | |
| 24 | + | |
| 25 | + private String name; | |
| 26 | + | |
| 27 | + public static ChatConversationTypeEnum valueOfType(String type) { | |
| 28 | + for (ChatConversationTypeEnum itemEnum : ChatConversationTypeEnum.values()) { | |
| 29 | + if (itemEnum.getType().equals(type)) { | |
| 30 | + return itemEnum; | |
| 31 | + } | |
| 32 | + } | |
| 33 | + throw new IllegalArgumentException("Invalid MessageType value: " + type); | |
| 34 | + } | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dataobject/AiChatConversationDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.dataobject; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.experimental.Accessors; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * chat 交谈 | |
| 11 | + * | |
| 12 | + * @author fansili | |
| 13 | + * @time 2024/4/14 17:35 | |
| 14 | + * @since 1.0 | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +@Accessors(chain = true) | |
| 18 | +@TableName("ai_chat_conversation") | |
| 19 | +public class AiChatConversationDO extends BaseDO { | |
| 20 | + | |
| 21 | + @Schema(description = "id") | |
| 22 | + private Long id; | |
| 23 | + | |
| 24 | + @Schema(description = "用户id") | |
| 25 | + private Long userId; | |
| 26 | + | |
| 27 | + @Schema(description = "chat角色Id") | |
| 28 | + private Long chatRoleId; | |
| 29 | + | |
| 30 | + @Schema(description = "chat角色名称") | |
| 31 | + private String chatRoleName; | |
| 32 | + | |
| 33 | + @Schema(description = "对话标题(有程序自动生成)") | |
| 34 | + private String chatTitle; | |
| 35 | + | |
| 36 | + @Schema(description = "对话标题(有程序自动生成)") | |
| 37 | + private Integer chatCount; | |
| 38 | + | |
| 39 | + @Schema(description = "对话类型(roleChat、userChat)") | |
| 40 | + private String chatType; | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatConversationMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.mapper; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.module.ai.dataobject.AiChatConversationDO; | |
| 5 | +import org.apache.ibatis.annotations.Mapper; | |
| 6 | +import org.apache.ibatis.annotations.Param; | |
| 7 | +import org.apache.ibatis.annotations.Update; | |
| 8 | +import org.springframework.stereotype.Repository; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * message mapper | |
| 12 | + * | |
| 13 | + * @fansili | |
| 14 | + * @since v1.0 | |
| 15 | + */ | |
| 16 | +@Repository | |
| 17 | +@Mapper | |
| 18 | +public interface AiChatConversationMapper extends BaseMapperX<AiChatConversationDO> { | |
| 19 | + | |
| 20 | + | |
| 21 | + @Update("update ai_chat_conversation set chat_count = chat_count + 1 where id = #{id}") | |
| 22 | + void updateIncrChatCount(@Param("id") Long id); | |
| 23 | + | |
| 24 | +} | ... | ... |