refacotr code
This commit is contained in:
parent
e11157ec41
commit
095efe428a
|
|
@ -10,7 +10,7 @@ import lombok.experimental.Accessors;
|
|||
@TableName(value = "ai_question_record")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AiQuestionRecord extends BaseModel{
|
||||
public class AiQuestionRecord extends BaseModel {
|
||||
|
||||
private String id;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.springframework.ai.chat.client.ChatClient;
|
|||
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
|
||||
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.document.DocumentReader;
|
||||
|
|
@ -35,7 +36,6 @@ import org.springframework.ai.reader.TextReader;
|
|||
import org.springframework.ai.reader.pdf.PagePdfDocumentReader;
|
||||
import org.springframework.ai.transformer.splitter.TokenTextSplitter;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -52,32 +52,25 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class ChatService {
|
||||
|
||||
private static final List<String> ALLOWS_FILE_TYPES = List.of("doc", "docx", "txt", "csv", "xls", "xlsx", "pdf", "ppt", "pptx");
|
||||
@Resource
|
||||
private VectorStore vectorStore;
|
||||
|
||||
@Resource
|
||||
private OllamaChatModel model;
|
||||
|
||||
@Resource
|
||||
private MessageChatMemoryAdvisor messageChatMemoryAdvisor;
|
||||
|
||||
@Resource
|
||||
private QuestionAnswerAdvisor questionAnswerAdvisor;
|
||||
|
||||
@Resource
|
||||
private AiFileUploadRecordMapper aiFileUploadRecordMapper;
|
||||
|
||||
@Resource
|
||||
private AiQuestionRecordMapper aiQuestionRecordMapper;
|
||||
|
||||
@Resource
|
||||
private ElePropertyConfig elePropertyConfig;
|
||||
|
||||
private static final List<String> ALLOWS_FILE_TYPES = List.of("doc", "docx", "txt", "csv", "xls", "xlsx", "pdf", "ppt", "pptx");
|
||||
|
||||
public ElectromagneticResult<?> deleteDocument(List<String> ids) {
|
||||
List<String> vectorIds = aiFileUploadRecordMapper.selectList(Wrappers.lambdaQuery(AiFileUploadRecord.class)
|
||||
.in(AiFileUploadRecord::getId, ids))
|
||||
.in(AiFileUploadRecord::getId, ids))
|
||||
.stream()
|
||||
.map(AiFileUploadRecord::getVectorId)
|
||||
.collect(Collectors.toList());
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import com.electromagnetic.industry.software.manage.service.FileFormatService;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class FileFormatServiceImpl extends ServiceImpl<FileFormatMapper, FileFormat> implements FileFormatService {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ spring.datasource.username=em_user_dev
|
|||
spring.datasource.password=Szsd#2O25$dev
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
# es
|
||||
spring.elasticsearch.password=123456
|
||||
spring.elasticsearch.username=elastic
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
// documents = documents.subList(0, 200);
|
||||
// vectorStore.write(documents);
|
||||
//
|
||||
//// Path tempFile = Paths.get(file.getAbsolutePath());
|
||||
//// DocumentReader documentReader = new TextReader(String.valueOf(tempFile.toUri().toURL()));
|
||||
//// List<Document> documents = documentReader.get();
|
||||
//// vectorStore.write(documents);
|
||||
/// / Path tempFile = Paths.get(file.getAbsolutePath());
|
||||
/// / DocumentReader documentReader = new TextReader(String.valueOf(tempFile.toUri().toURL()));
|
||||
/// / List<Document> documents = documentReader.get();
|
||||
/// / vectorStore.write(documents);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
public class PageFile {
|
||||
|
||||
private int pageNumber;
|
||||
private int pageNumber;
|
||||
|
||||
private String content;
|
||||
private String content;
|
||||
|
||||
private String fileName;
|
||||
private String fileName;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue