feat #565: add vector knowledge ingestion demo
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.cloudhandson.vpdbackoffice.service;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class VectorChunkerTest {
|
||||
|
||||
@Test
|
||||
void keepsParagraphsTogetherUntilTheConfiguredLimit() {
|
||||
var chunks = VectorChunker.chunk(
|
||||
"첫 번째 문단입니다.\n\n두 번째 문단은 같은 지식자료입니다.", 80);
|
||||
|
||||
assertThat(chunks).hasSize(1);
|
||||
assertThat(chunks.get(0).chunkNo()).isEqualTo(1);
|
||||
assertThat(chunks.get(0).text()).contains("첫 번째", "두 번째");
|
||||
}
|
||||
|
||||
@Test
|
||||
void splitsLongTextAndNumbersChunksFromOne() {
|
||||
var chunks = VectorChunker.chunk("문장 하나입니다. ".repeat(30), 100);
|
||||
|
||||
assertThat(chunks).hasSizeGreaterThan(1);
|
||||
assertThat(chunks).extracting("chunkNo").containsExactlyElementsOf(
|
||||
java.util.stream.IntStream.rangeClosed(1, chunks.size()).boxed().toList());
|
||||
assertThat(chunks).allSatisfy(chunk -> assertThat(chunk.text()).isNotBlank());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsBlankContent() {
|
||||
assertThatThrownBy(() -> VectorChunker.chunk(" ", 600))
|
||||
.isInstanceOf(AppException.class)
|
||||
.hasMessageContaining("청킹할 문서 본문");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user