将AI中支持上传的文件类型转移到配置文件
This commit is contained in:
parent
832ed737bf
commit
881e5bf5c9
|
|
@ -6,6 +6,8 @@ import lombok.Getter;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ElePropertyConfig {
|
public class ElePropertyConfig {
|
||||||
|
|
||||||
|
|
@ -73,6 +75,13 @@ public class ElePropertyConfig {
|
||||||
@Value("${prjRootPath}")
|
@Value("${prjRootPath}")
|
||||||
private String prjRootPath;
|
private String prjRootPath;
|
||||||
|
|
||||||
|
@Value("${allow.upload.file.types}")
|
||||||
|
private String allowUploadFileTypes;
|
||||||
|
|
||||||
|
public List<String> getAiAllowUploadFileTypes() {
|
||||||
|
return List.of(allowUploadFileTypes.split(","));
|
||||||
|
}
|
||||||
|
|
||||||
public String getEleTmpPath() {
|
public String getEleTmpPath() {
|
||||||
if (EleCommonUtil.isWinOs()) {
|
if (EleCommonUtil.isWinOs()) {
|
||||||
return winPrefix + prjRootPath + eleTmpPath;
|
return winPrefix + prjRootPath + eleTmpPath;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ import java.util.*;
|
||||||
@Service
|
@Service
|
||||||
public class ChatService {
|
public class ChatService {
|
||||||
|
|
||||||
private static final List<String> ALLOWS_FILE_TYPES = List.of("doc", "docx", "txt", "csv", "xls", "xlsx", "pdf", "ppt", "pptx");
|
|
||||||
@Resource
|
@Resource
|
||||||
private VectorStore vectorStore;
|
private VectorStore vectorStore;
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -90,7 +89,7 @@ public class ChatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileType = FileUtil.extName(file.getOriginalFilename());
|
String fileType = FileUtil.extName(file.getOriginalFilename());
|
||||||
if (!ALLOWS_FILE_TYPES.contains(fileType)) {
|
if (!elePropertyConfig.getAiAllowUploadFileTypes().contains(fileType)) {
|
||||||
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("当前格式 {} 不支持", fileType));
|
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("当前格式 {} 不支持", fileType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ spring.ai.vectorstore.elasticsearch.initialize-schema=true
|
||||||
spring.ai.vectorstore.elasticsearch.index-name=rag
|
spring.ai.vectorstore.elasticsearch.index-name=rag
|
||||||
spring.ai.vectorstore.elasticsearch.dimensions=768
|
spring.ai.vectorstore.elasticsearch.dimensions=768
|
||||||
spring.ai.vectorstore.elasticsearch.similarity=cosine
|
spring.ai.vectorstore.elasticsearch.similarity=cosine
|
||||||
|
allow.upload.file.types=doc, docx, txt, csv, xls, xlsx, pdf, ppt", pptx
|
||||||
# mybatis
|
# mybatis
|
||||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue