ai模块修改

This commit is contained in:
2025-12-15 15:26:05 +08:00
parent 3767150fd6
commit 8a03ede7dc
56 changed files with 3403 additions and 1119 deletions

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xyzh</groupId>
<artifactId>apis</artifactId>
<version>1.0.0</version>
</parent>
<groupId>org.xyzh.apis</groupId>
<artifactId>api-ai</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
</project>

View File

@@ -0,0 +1,9 @@
package org.xyzh.api.ai;
/**
* Agent服务接口
* 用于知识库和文档管理
*/
public interface AgentService {
}

View File

@@ -0,0 +1,99 @@
package org.xyzh.api.ai.dto;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
/**
* @description Dify文件信息用于对话文件上传和请求
* @filename DifyFileInfo.java
* @author AI Assistant
* @copyright xyzh
* @since 2025-12-15
*/
@Data
public class DifyFileInfo {
/**
* 文件IDDify返回
*/
private String id;
/**
* 文件名
*/
private String name;
/**
* 文件大小(字节)
*/
private Integer size;
/**
* 文件扩展名
*/
private String extension;
/**
* 文件MIME类型
*/
@JSONField(name = "mime_type")
private String mimeType;
/**
* 上传人ID
*/
@JSONField(name = "created_by")
private String createdBy;
/**
* 上传时间(时间戳)
*/
@JSONField(name = "created_at")
private Long createdAt;
/**
* 预览URL
*/
@JSONField(name = "preview_url")
private String previewUrl;
/**
* 源文件URL
*/
@JSONField(name = "source_url")
private String sourceUrl;
/**
* 文件类型image、document、audio、video、file
*/
private String type;
/**
* 传输方式remote_url、local_file
*/
@JSONField(name = "transfer_method")
private String transferMethod;
/**
* 文件URL或ID
*/
private String url;
/**
* 本地文件上传ID
*/
@JSONField(name = "upload_file_id")
private String uploadFileId;
/**
* 系统文件ID
*/
@JSONField(name = "sys_file_id")
private String sysFileId;
/**
* 文件路径(从系统文件表获取)
*/
@JSONField(name = "file_path")
private String filePath;
}

View File

@@ -0,0 +1,14 @@
package org.xyzh.api.ai.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "智能体提示卡")
public class PromptCard {
@Schema(description = "文件ID")
private String fileId;
@Schema(description = "提示词")
private String prompt;
}

View File

@@ -0,0 +1,41 @@
package org.xyzh.api.ai.dto;
import java.util.List;
import org.xyzh.common.dto.BaseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.v3.oas.annotations.media.Schema;
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "系统文件DTO")
public class TbAgent extends BaseDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "智能体ID")
private String agentId;
@Schema(description = "智能体名称")
private String name;
@Schema(description = "智能体描述")
private String description;
@Schema(description = "智能体url")
private String link;
@Schema(description = "智能体APIKEY")
private String apiKey;
@Schema(description = "引导词")
private String introduce;
@Schema(description = "提示卡片数组")
private List<PromptCard> promptCards;
@Schema(description = "分类")
private String category;
}

View File

@@ -0,0 +1,25 @@
package org.xyzh.api.ai.dto;
import org.xyzh.common.dto.BaseDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "AI智能体对话")
public class TbChat extends BaseDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "对话ID")
private String chatId;
@Schema(description = "智能体ID")
private String agentId;
@Schema(description = "用户ID")
private String userId;
@Schema(description = "对话标题")
private String title;
}

View File

@@ -0,0 +1,30 @@
package org.xyzh.api.ai.dto;
import java.util.List;
import org.xyzh.common.dto.BaseDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "AI智能体对话消息")
public class TbChatMessage extends BaseDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "消息ID")
private String messageId;
@Schema(description = "对话ID")
private String chatId;
@Schema(description = "角色")
private String role;
@Schema(description = "内容")
private String content;
@Schema(description = "文件ID数组")
private List<String> files;
}

View File

@@ -0,0 +1,68 @@
package org.xyzh.api.ai.dto;
import org.xyzh.common.dto.BaseDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "知识库配置")
public class TbKnowledge extends BaseDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "知识库ID")
private String knowledgeId;
@Schema(description = "知识库标题")
private String title;
@Schema(description = "知识库头像")
private String avatar;
@Schema(description = "知识库描述")
private String description;
@Schema(description = "Dify知识库IDDataset ID")
private String difyDatasetId;
@Schema(description = "Dify索引方式high_quality/economy")
private String difyIndexingTechnique;
@Schema(description = "向量模型名称")
private String embeddingModel;
@Schema(description = "向量模型提供商")
private String embeddingModelProvider;
@Schema(description = "Rerank模型名称")
private String rerankModel;
@Schema(description = "Rerank模型提供商")
private String rerankModelProvider;
@Schema(description = "是否启用Rerank0否 1是")
private Integer rerankingEnable;
@Schema(description = "检索Top K返回前K个结果")
private Integer retrievalTopK;
@Schema(description = "检索分数阈值0.00-1.00")
private Double retrievalScoreThreshold;
@Schema(description = "文档数量")
private Integer documentCount;
@Schema(description = "总分段数")
private Integer totalChunks;
@Schema(description = "所属服务 workcase、bidding")
private String service;
@Schema(description = "bidding所属项目ID")
private String projectId;
@Schema(description = "所属分类 workcase 内部知识库、外部知识库")
private String category;
}

View File

@@ -0,0 +1,28 @@
package org.xyzh.api.ai.dto;
import org.xyzh.common.dto.BaseDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "知识库文件")
public class TbKnowledgeFile extends BaseDTO{
private final static long serialVersionUID = 1L;
@Schema(description = "知识库ID")
private String knowledgeId;
@Schema(description = "文件ID")
private String fileId;
@Schema(description = "文件根ID")
private String fileRootId;
@Schema(description = "Dify文件ID")
private String difyFileId;
@Schema(description = "文件版本")
private String version;
}

View File

@@ -0,0 +1,12 @@
package org.xyzh.api.ai.vo;
import org.xyzh.common.vo.BaseVO;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
@Data
@Schema(description = "智能体VO")
public class AgentVO extends BaseVO{
}