Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void testDocumentNotDividedViaHorizontalRulesWhenIsDisabled() {

Document documentsFirst = documents.get(0);
assertThat(documentsFirst.getMetadata()).isEmpty();
assertThat(documentsFirst.getContent()).startsWith("Lorem ipsum dolor sit amet, consectetur adipiscing elit")
assertThat(documentsFirst.getText()).startsWith("Lorem ipsum dolor sit amet, consectetur adipiscing elit")
.endsWith("Phasellus eget tellus sed nibh ornare interdum eu eu mi.");
}

Expand All @@ -119,7 +119,7 @@ void testSimpleMarkdownDocumentWithHardAndSoftLineBreaks() {

Document documentsFirst = documents.get(0);
assertThat(documentsFirst.getMetadata()).isEmpty();
assertThat(documentsFirst.getContent()).isEqualTo(
assertThat(documentsFirst.getText()).isEqualTo(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt velit non bibendum gravida. Cras accumsan tincidunt ornare. Donec hendrerit consequat tellus blandit accumsan. Aenean aliquam metus at arcu elementum dignissim.Nullam nisi dui, egestas nec sem nec, interdum lobortis enim. Pellentesque odio orci, faucibus eu luctus nec, venenatis et magna. Vestibulum nec eros non felis fermentum posuere eget ac risus.Aenean eu leo eu nibh tristique posuere quis quis massa. Nullam lacinia luctus sem ut vehicula.");
}

Expand All @@ -135,22 +135,22 @@ void testCode() {

assertThat(documents).satisfiesExactly(document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of());
assertThat(document.getContent()).isEqualTo("This is a Java sample application:");
assertThat(document.getText()).isEqualTo("This is a Java sample application:");
}, document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of("lang", "java", "category", "code_block"));
assertThat(document.getContent()).startsWith("package com.example.demo;")
assertThat(document.getText()).startsWith("package com.example.demo;")
.contains("SpringApplication.run(DemoApplication.class, args);");
}, document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of("category", "code_inline"));
assertThat(document.getContent()).isEqualTo(
assertThat(document.getText()).isEqualTo(
"Markdown also provides the possibility to use inline code formatting throughout the entire sentence.");
}, document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of());
assertThat(document.getContent())
assertThat(document.getText())
.isEqualTo("Another possibility is to set block code without specific highlighting:");
}, document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of("lang", "", "category", "code_block"));
assertThat(document.getContent()).isEqualTo("./mvnw spring-javaformat:apply\n");
assertThat(document.getText()).isEqualTo("./mvnw spring-javaformat:apply\n");
});
}

Expand All @@ -167,15 +167,15 @@ void testCodeWhenCodeBlockShouldNotBeSeparatedDocument() {

assertThat(documents).satisfiesExactly(document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of("lang", "java", "category", "code_block"));
assertThat(document.getContent()).startsWith("This is a Java sample application: package com.example.demo")
assertThat(document.getText()).startsWith("This is a Java sample application: package com.example.demo")
.contains("SpringApplication.run(DemoApplication.class, args);");
}, document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of("category", "code_inline"));
assertThat(document.getContent()).isEqualTo(
assertThat(document.getText()).isEqualTo(
"Markdown also provides the possibility to use inline code formatting throughout the entire sentence.");
}, document -> {
assertThat(document.getMetadata()).isEqualTo(Map.of("lang", "", "category", "code_block"));
assertThat(document.getContent()).isEqualTo(
assertThat(document.getText()).isEqualTo(
"Another possibility is to set block code without specific highlighting: ./mvnw spring-javaformat:apply\n");
});
}
Expand Down Expand Up @@ -208,7 +208,7 @@ void testBlockquoteWhenBlockquoteShouldNotBeSeparatedDocument() {

Document documentsFirst = documents.get(0);
assertThat(documentsFirst.getMetadata()).isEqualTo(Map.of("category", "blockquote"));
assertThat(documentsFirst.getContent()).isEqualTo(
assertThat(documentsFirst.getText()).isEqualTo(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur diam eros, laoreet sit amet cursus vitae, varius sed nisi. Cras sit amet quam quis velit commodo porta consectetur id nisi. Phasellus tincidunt pulvinar augue. Proin vel laoreet leo, sed luctus augue. Sed et ligula commodo, commodo lacus at, consequat turpis. Maecenas eget sapien odio. Maecenas urna lectus, pellentesque in accumsan aliquam, congue eu libero. Ut rhoncus nec justo a porttitor. Pellentesque auctor pharetra eros, viverra sodales lorem aliquet id. Curabitur semper nisi vel sem interdum suscipit.");
}

Expand Down Expand Up @@ -241,7 +241,7 @@ void testWithAdditionalMetadata() {

Document documentsFirst = documents.get(0);
assertThat(documentsFirst.getMetadata()).isEqualTo(Map.of("service", "some-service-name", "env", "prod"));
assertThat(documentsFirst.getContent()).startsWith("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
assertThat(documentsFirst.getText()).startsWith("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public List<Document> get() {
while (itr.hasNext()) {
var next = itr.next();
Document document = toDocument(current, next);
if (document != null && StringUtils.hasText(document.getContent())) {
if (document != null && StringUtils.hasText(document.getText())) {
documents.add(toDocument(current, next));
}
current = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testDocx(String resourceUri, String resourceName, String contentSnip

assertThat(doc.getMetadata()).containsKeys(TikaDocumentReader.METADATA_SOURCE);
assertThat(doc.getMetadata().get(TikaDocumentReader.METADATA_SOURCE)).isEqualTo(resourceName);
assertThat(doc.getContent()).contains(contentSnipped);
assertThat(doc.getText()).contains(contentSnipped);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void main(String[] args) {
String modelId = "anthropic.claude-3-5-sonnet-20240620-v1:0";

// var prompt = new Prompt("Tell me a joke?",
// ChatOptionsBuilder.builder().withModel(modelId).build());
// ChatOptions.builder().model(modelId).build();
var prompt = new Prompt(
// "What's the weather like in San Francisco, Tokyo, and Paris? Return the
// temperature in Celsius.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) {
String modelId = "anthropic.claude-3-5-sonnet-20240620-v1:0";

// var prompt = new Prompt("Tell me a joke?",
// ChatOptionsBuilder.builder().withModel(modelId).build());
// ChatOptions.builder().model(modelId).build();
var prompt = new Prompt(
// "What's the weather like in San Francisco, Tokyo, and Paris? Return the
// temperature in Celsius.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public BedrockCohereEmbeddingModel(CohereEmbeddingBedrockApi cohereEmbeddingBedr

@Override
public float[] embed(Document document) {
return embed(document.getContent());
return embed(document.getText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public BedrockTitanEmbeddingModel withInputType(InputType inputType) {

@Override
public float[] embed(Document document) {
return embed(document.getContent());
return embed(document.getText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public EmbeddingResponse call(EmbeddingRequest request) {

@Override
public float[] embed(Document document) {
return embed(document.getContent());
return embed(document.getText());
}

private EmbeddingResponse embedAllWithContext(List<EmbedTextRequest> embedTextRequests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static Builder builder() {

@Override
public float[] embed(Document document) {
return embed(document.getContent());
return embed(document.getText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void acmeChain() {
private Message getSystemMessage(List<Document> similarDocuments) {

String documents = similarDocuments.stream()
.map(entry -> entry.getContent())
.map(entry -> entry.getText())
.collect(Collectors.joining(System.lineSeparator()));

SystemPromptTemplate systemPromptTemplate = new SystemPromptTemplate(this.systemBikePrompt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ private EmbeddingResponse doSingleDocumentPrediction(PredictionServiceClient cli
}

// optional text parameter
if (StringUtils.hasText(document.getContent())) {
instanceBuilder.text(document.getContent());
if (StringUtils.hasText(document.getText())) {
instanceBuilder.text(document.getText());
documentMetadata.put(ModalityType.TEXT,
new DocumentMetadata(document.getId(), MimeTypeUtils.TEXT_PLAIN, document.getContent()));
new DocumentMetadata(document.getId(), MimeTypeUtils.TEXT_PLAIN, document.getText()));
}

Media media = document.getMedia();
Expand All @@ -153,7 +153,7 @@ private EmbeddingResponse doSingleDocumentPrediction(PredictionServiceClient cli
instanceBuilder.text(media.getData().toString());
documentMetadata.put(ModalityType.TEXT,
new DocumentMetadata(document.getId(), MimeTypeUtils.TEXT_PLAIN, media.getData()));
if (StringUtils.hasText(document.getContent())) {
if (StringUtils.hasText(document.getText())) {
logger.warn("Media type String overrides the Document text content!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public WatsonxAiEmbeddingModel(WatsonxAiApi watsonxAiApi, WatsonxAiEmbeddingOpti

@Override
public float[] embed(Document document) {
return embed(document.getContent());
return embed(document.getText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,42 +274,6 @@ public AbstractBuilder order(int order) {
return this;
}

/**
* @deprecated use {@link #conversationId( String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public AbstractBuilder withConversationId(String conversationId) {
this.conversationId = conversationId;
return this;
}

/**
* @deprecated use {@link #chatMemoryRetrieveSize(int)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public AbstractBuilder withChatMemoryRetrieveSize(int chatMemoryRetrieveSize) {
this.chatMemoryRetrieveSize = chatMemoryRetrieveSize;
return this;
}

/**
* @deprecated use {@link #protectFromBlocking(boolean)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public AbstractBuilder withProtectFromBlocking(boolean protectFromBlocking) {
this.protectFromBlocking = protectFromBlocking;
return this;
}

/**
* @deprecated use {@link #order(int)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public AbstractBuilder withOrder(int order) {
this.order = order;
return this;
}

/**
* Build the advisor.
* @return the advisor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ public Builder systemTextAdvise(String systemTextAdvise) {
return this;
}

/**
* @deprecated use {@link #systemTextAdvise(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSystemTextAdvise(String systemTextAdvise) {
this.systemTextAdvise = systemTextAdvise;
return this;
}

public PromptChatMemoryAdvisor build() {
return new PromptChatMemoryAdvisor(this.chatMemory, this.conversationId, this.chatMemoryRetrieveSize,
this.systemTextAdvise, this.order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,44 +309,6 @@ public Builder order(int order) {
return this;
}

/**
* @deprecated use {@link #searchRequest(SearchRequest)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSearchRequest(SearchRequest searchRequest) {
Assert.notNull(searchRequest, "The searchRequest must not be null!");
this.searchRequest = searchRequest;
return this;
}

/**
* @deprecated use {@link #userTextAdvise(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withUserTextAdvise(String userTextAdvise) {
Assert.hasText(userTextAdvise, "The userTextAdvise must not be empty!");
this.userTextAdvise = userTextAdvise;
return this;
}

/**
* @deprecated use {@link #protectFromBlocking(boolean)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withProtectFromBlocking(boolean protectFromBlocking) {
this.protectFromBlocking = protectFromBlocking;
return this;
}

/**
* @deprecated use {@link #order(int)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withOrder(int order) {
this.order = order;
return this;
}

public QuestionAnswerAdvisor build() {
return new QuestionAnswerAdvisor(this.vectorStore, this.searchRequest, this.userTextAdvise,
this.protectFromBlocking, this.order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,6 @@ public Builder order(int order) {
return this;
}

/**
* @deprecated use {@link #sensitiveWords(List)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSensitiveWords(List<String> sensitiveWords) {
this.sensitiveWords = sensitiveWords;
return this;
}

/**
* @deprecated use {@link #failureResponse(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withFailureResponse(String failureResponse) {
this.failureResponse = failureResponse;
return this;
}

/**
* @deprecated use {@link #order(int)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withOrder(int order) {
this.order = order;
return this;
}

public SafeGuardAdvisor build() {
return new SafeGuardAdvisor(this.sensitiveWords, this.failureResponse, this.order);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ public Builder systemTextAdvise(String systemTextAdvise) {
return this;
}

/**
* @deprecated use {@link #systemTextAdvise(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSystemTextAdvise(String systemTextAdvise) {
this.systemTextAdvise = systemTextAdvise;
return this;
}

@Override
public VectorStoreChatMemoryAdvisor build() {
return new VectorStoreChatMemoryAdvisor(this.chatMemory, this.conversationId, this.chatMemoryRetrieveSize,
Expand Down
Loading
Loading