Long libraryId

This commit is contained in:
Chuck1sn
2025-06-27 22:57:00 +08:00
parent 4d70b49e61
commit 6ec07686a9
2 changed files with 3 additions and 2 deletions

View File

@@ -85,7 +85,7 @@ public class LibraryController {
Long libraryDocId =
ragService.createLibraryDocBy(
Long.valueOf(libraryId), objectName, multipartFile.getOriginalFilename());
ragService.embeddingAndCreateDocSegment(libraryDocId, objectName);
ragService.embeddingAndCreateDocSegment(Long.valueOf(libraryId), libraryDocId, objectName);
return objectName;
}
}

View File

@@ -109,7 +109,7 @@ public class RagService {
}
@Async
public void embeddingAndCreateDocSegment(Long libraryDocId, String objectName) {
public void embeddingAndCreateDocSegment(Long libraryId, Long libraryDocId, String objectName) {
Document document =
amazonS3DocumentLoader.loadDocument(
minIoConfig.getDefaultBucket(), objectName, new ApacheTikaDocumentParser());
@@ -123,6 +123,7 @@ public class RagService {
Response<Embedding> embed = zhipuEmbeddingModel.embed(textSegment);
Integer tokenUsage = embed.tokenUsage().totalTokenCount();
Embedding vector = embed.content();
textSegment.metadata().put("libraryId", libraryId);
String embeddingId = zhiPuLibraryEmbeddingStore.add(vector, textSegment);
LibraryDocSegment libraryDocSegment = new LibraryDocSegment();
libraryDocSegment.setEmbeddingId(embeddingId);