clean code

This commit is contained in:
chenxudong 2025-04-03 16:48:22 +08:00
parent 2e1de849b2
commit 218a2af06e
1 changed files with 1 additions and 3 deletions

View File

@ -24,7 +24,6 @@ import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.document.Document; import org.springframework.ai.document.Document;
import org.springframework.ai.ollama.OllamaChatModel; import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.reader.pdf.PagePdfDocumentReader; import org.springframework.ai.reader.pdf.PagePdfDocumentReader;
import org.springframework.ai.reader.pdf.config.PdfDocumentReaderConfig;
import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.chat.model.ChatResponse; import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -107,8 +106,7 @@ public class ChatService {
} }
Path tempFile = saveUploadedFileToTemp(file); Path tempFile = saveUploadedFileToTemp(file);
PdfDocumentReaderConfig config = PdfDocumentReaderConfig.builder().build(); PagePdfDocumentReader reader = new PagePdfDocumentReader(String.valueOf(tempFile.toUri().toURL()));
PagePdfDocumentReader reader = new PagePdfDocumentReader(String.valueOf(tempFile.toUri().toURL()), config);
List<Document> documents = reader.get(); List<Document> documents = reader.get();
Files.deleteIfExists(tempFile); Files.deleteIfExists(tempFile);
vectorStore.write(documents); vectorStore.write(documents);