add other format for vector

This commit is contained in:
2026-03-17 00:03:01 +01:00
parent 30e69ccbb3
commit 69349a8788
5 changed files with 17 additions and 6 deletions

View File

@@ -137,6 +137,10 @@
<groupId>org.springframework.kafka</groupId> <groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId> <artifactId>spring-kafka</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-tika-document-reader</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

View File

@@ -20,6 +20,7 @@ import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import org.springframework.ai.reader.tika.TikaDocumentReader;
import java.io.IOException; import java.io.IOException;
import java.security.MessageDigest; import java.security.MessageDigest;
@@ -177,7 +178,13 @@ public class UserDocumentServiceImpl implements UserDocumentService {
} }
}; };
List<Document> docs = new TextReader(resource).get(); List<Document> docs;
String ext = getExtensionOrTxt(filename);
if (ext.equals("txt")) {
docs = new TextReader(resource).get();
} else {
docs = new TikaDocumentReader(resource).get();
}
TokenTextSplitter splitter = TokenTextSplitter.builder() TokenTextSplitter splitter = TokenTextSplitter.builder()
.withChunkSize(chunkSize) .withChunkSize(chunkSize)

View File

@@ -24,6 +24,9 @@ spring.cloud.consul.discovery.deregister-critical-service-after=1m
management.endpoints.web.exposure.include=health,info management.endpoints.web.exposure.include=health,info
management.endpoint.health.show-details=always management.endpoint.health.show-details=always
spring.servlet.multipart.max-file-size=5MB
spring.servlet.multipart.max-request-size=10MB
spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/ragdb} spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/ragdb}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres} spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres} spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres}

View File

@@ -29,12 +29,9 @@ export const PREFIX_UPLOAD_STREAM = "/upload-stream";
export const FORM_DATA_FILES = "files"; export const FORM_DATA_FILES = "files";
export const TYPE_WINDOW_UNDEFINED = "undefined"; export const TYPE_WINDOW_UNDEFINED = "undefined";
export const TOKEN_UNDEFINED = "undefined"; export const TOKEN_UNDEFINED = "undefined";
export const MAX_FILE_SIZE_KB = 10; export const MAX_FILE_SIZE_KB = 2048;
export const MAX_FILES_TO_UPLOAD = 3; export const MAX_FILES_TO_UPLOAD = 3;
export const DEFAULT_ERROR_STATUS = 500; export const DEFAULT_ERROR_STATUS = 500;
export const FULFILLED_BUT_NOT_SUCCESS_ERROR_STATUS = 999;
export const UNKNOWN_ERROR_AFTER_FULFILLED_QUERY =
"Unknown error after fulfilled query";
export const UNKNOWN_ERROR = "Unknown error"; export const UNKNOWN_ERROR = "Unknown error";
export const STATUS_UNAUTHORIZED = "unauthorized"; export const STATUS_UNAUTHORIZED = "unauthorized";
export const HTTP_STATUS_UNAUTHORIZED_CODE = 401; export const HTTP_STATUS_UNAUTHORIZED_CODE = 401;

View File

@@ -28,7 +28,7 @@ const FileSelector = ({ disabled, onFilesChange }) => {
<input <input
ref={fileInputRef} ref={fileInputRef}
type="file" type="file"
accept=".txt" accept=".txt,.pdf,.docx,.doc,.md,.rtf,.html"
multiple multiple
style={{ display: "none" }} style={{ display: "none" }}
onChange={onFilesChange} onChange={onFilesChange}