Commit 84618d9a authored by 林洋洋's avatar 林洋洋

切片相关代码提交

parent 3344c79c
package com.ask.api.dto;
import com.ask.api.entity.SysFile;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 文档分段请求DTO
*
* @author ai
* @date 2024/12/19
*/
@Data
@Schema(description = "文档分段请求参数")
public class DocumentSegmentRequest {
@NotNull(message ="知识库ID不能为空")
@Schema(description = "知识库ID", required = true, example = "1")
private Long knowledgeBaseId;
@NotEmpty(message ="文件数组不能为空")
@Schema(description = "文件数组", required = true)
private List<SysFile> files;
}
\ No newline at end of file
package com.ask.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
/**
* 文件上传请求DTO
*
* @author ai
* @date 2024/12/19
*/
@Data
@Schema(description = "文件上传请求参数")
public class FileUploadRequest {
@NotNull(message = "存储桶名称不能为空")
@Schema(description = "存储桶名称/ID,用于文件分类存储", required = true, example = "1")
private Long bucketName;
@NotEmpty(message = "文件数组不能为空")
@Schema(description = "文件数组,支持多文件上传", required = true)
private MultipartFile[] files;
}
\ No newline at end of file
package com.ask.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 向量存储实体
*
* @author ai
* @date 2024/12/20
*/
@Data
@TableName("ask_vector_store")
@Schema(description = "向量存储")
public class AskVectorStore implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_UUID)
@Schema(description = "主键ID")
private String id;
/**
* 文档内容
*/
@Schema(description = "文档内容")
private String content;
/**
* 文档元数据(JSON格式)
* 包含: vectorized, status, knowledgeDocumentId, segmentIndex, createBy, createTime 等
*/
@Schema(description = "文档元数据")
private String metadata;
@Schema(description = "文档ID")
private Long documentId;
@Schema(description = "标题")
private String title;
@Schema(description = "启用状态")
private Integer isEnabled;
}
\ No newline at end of file
package com.ask.mapper;
import com.ask.api.entity.AskVectorStore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 向量存储Mapper接口
*
* @author ai
* @date 2024/12/20
*/
@Mapper
public interface AskVectorStoreMapper extends BaseMapper<AskVectorStore> {
}
\ No newline at end of file
package com.ask.service;
import com.ask.api.entity.AskVectorStore;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.ai.document.Document;
import java.util.List;
/**
* 向量存储Service接口
*
* @author ai
* @date 2024/12/20
*/
public interface AskVectorStoreService extends IService<AskVectorStore> {
}
\ No newline at end of file
package com.ask.service.impl;
import com.ask.api.entity.AskVectorStore;
import com.ask.mapper.AskVectorStoreMapper;
import com.ask.service.AskVectorStoreService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.document.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* 向量存储Service实现类
*
* @author ai
* @date 2024/12/20
*/
@Slf4j
@Service
public class AskVectorStoreServiceImpl extends ServiceImpl<AskVectorStoreMapper, AskVectorStore> implements AskVectorStoreService {
}
\ No newline at end of file
package com.ask.common.config;
import com.ask.common.core.FileTemplate;
import com.ask.common.local.LocalFileTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 文件配置类
*/
@Configuration
public class FileConfig {
@Value("${file.local.base-path:./uploads}")
private String basePath;
@Bean
public FileTemplate fileTemplate() {
return new LocalFileTemplate(basePath);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment