Fix checkstyle errors
This commit is contained in:
@@ -102,7 +102,7 @@ public final class MultiQueryExpander implements QueryExpander {
|
||||
|
||||
var response = this.chatClient.prompt()
|
||||
.user(user -> user.text(this.promptTemplate.getTemplate())
|
||||
.param("number", numberOfQueries)
|
||||
.param("number", this.numberOfQueries)
|
||||
.param("query", query.text()))
|
||||
.call()
|
||||
.content();
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class TranslationQueryTransformer implements QueryTransformer {
|
||||
|
||||
var translatedQuery = this.chatClient.prompt()
|
||||
.user(user -> user.text(this.promptTemplate.getTemplate())
|
||||
.param("targetLanguage", targetLanguage)
|
||||
.param("targetLanguage", this.targetLanguage)
|
||||
.param("query", query.text()))
|
||||
.options(ChatOptionsBuilder.builder().withTemperature(0.0).build())
|
||||
.call()
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.rag.analysis.query.expansion;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.prompt.PromptTemplate;
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.rag.analysis.query.transformation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.prompt.PromptTemplate;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@@ -13,12 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests;
|
||||
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
|
||||
/**
|
||||
* Test configuration for Testcontainers-based Dev Services.
|
||||
|
||||
@@ -13,12 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests.client.advisor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.client.advisor.RetrievalAugmentationAdvisor;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
@@ -39,8 +43,6 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -65,15 +67,15 @@ class RetrievalAugmentationAdvisorIT {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
DocumentReader markdownReader = new MarkdownDocumentReader(knowledgeBaseResource,
|
||||
DocumentReader markdownReader = new MarkdownDocumentReader(this.knowledgeBaseResource,
|
||||
MarkdownDocumentReaderConfig.defaultConfig());
|
||||
knowledgeBaseDocuments = markdownReader.read();
|
||||
pgVectorStore.add(knowledgeBaseDocuments);
|
||||
this.knowledgeBaseDocuments = markdownReader.read();
|
||||
this.pgVectorStore.add(this.knowledgeBaseDocuments);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
pgVectorStore.delete(knowledgeBaseDocuments.stream().map(Document::getId).toList());
|
||||
this.pgVectorStore.delete(this.knowledgeBaseDocuments.stream().map(Document::getId).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,10 +83,10 @@ class RetrievalAugmentationAdvisorIT {
|
||||
String question = "Where does the adventure of Anacletus and Birba take place?";
|
||||
|
||||
RetrievalAugmentationAdvisor ragAdvisor = RetrievalAugmentationAdvisor.builder()
|
||||
.documentRetriever(VectorStoreDocumentRetriever.builder().vectorStore(pgVectorStore).build())
|
||||
.documentRetriever(VectorStoreDocumentRetriever.builder().vectorStore(this.pgVectorStore).build())
|
||||
.build();
|
||||
|
||||
ChatResponse chatResponse = ChatClient.builder(openAiChatModel)
|
||||
ChatResponse chatResponse = ChatClient.builder(this.openAiChatModel)
|
||||
.build()
|
||||
.prompt(question)
|
||||
.advisors(ragAdvisor)
|
||||
@@ -106,13 +108,13 @@ class RetrievalAugmentationAdvisorIT {
|
||||
|
||||
RetrievalAugmentationAdvisor ragAdvisor = RetrievalAugmentationAdvisor.builder()
|
||||
.queryTransformers(TranslationQueryTransformer.builder()
|
||||
.chatClientBuilder(ChatClient.builder(openAiChatModel))
|
||||
.chatClientBuilder(ChatClient.builder(this.openAiChatModel))
|
||||
.targetLanguage("english")
|
||||
.build())
|
||||
.documentRetriever(VectorStoreDocumentRetriever.builder().vectorStore(pgVectorStore).build())
|
||||
.documentRetriever(VectorStoreDocumentRetriever.builder().vectorStore(this.pgVectorStore).build())
|
||||
.build();
|
||||
|
||||
ChatResponse chatResponse = ChatClient.builder(openAiChatModel)
|
||||
ChatResponse chatResponse = ChatClient.builder(this.openAiChatModel)
|
||||
.build()
|
||||
.prompt(question)
|
||||
.advisors(ragAdvisor)
|
||||
@@ -132,7 +134,7 @@ class RetrievalAugmentationAdvisorIT {
|
||||
EvaluationRequest evaluationRequest = new EvaluationRequest(question,
|
||||
chatResponse.getMetadata().get(RetrievalAugmentationAdvisor.DOCUMENT_CONTEXT),
|
||||
chatResponse.getResult().getOutput().getContent());
|
||||
RelevancyEvaluator evaluator = new RelevancyEvaluator(ChatClient.builder(openAiChatModel));
|
||||
RelevancyEvaluator evaluator = new RelevancyEvaluator(ChatClient.builder(this.openAiChatModel));
|
||||
EvaluationResponse evaluationResponse = evaluator.evaluate(evaluationRequest);
|
||||
assertThat(evaluationResponse.isPass()).isTrue();
|
||||
}
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests.rag.analysis.query.expansion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.integration.tests.TestApplication;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
@@ -26,8 +30,6 @@ import org.springframework.ai.rag.analysis.query.expansion.QueryExpander;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -46,7 +48,7 @@ class MultiQueryExpanderIT {
|
||||
void whenExpanderWithDefaults() {
|
||||
Query query = new Query("What is the weather in Rome?");
|
||||
QueryExpander queryExpander = MultiQueryExpander.builder()
|
||||
.chatClientBuilder(ChatClient.builder(openAiChatModel))
|
||||
.chatClientBuilder(ChatClient.builder(this.openAiChatModel))
|
||||
.build();
|
||||
|
||||
List<Query> queries = queryExpander.apply(query);
|
||||
@@ -60,7 +62,7 @@ class MultiQueryExpanderIT {
|
||||
void whenExpanderWithCustomQueryNumber() {
|
||||
Query query = new Query("What is the weather in Rome?");
|
||||
QueryExpander queryExpander = MultiQueryExpander.builder()
|
||||
.chatClientBuilder(ChatClient.builder(openAiChatModel))
|
||||
.chatClientBuilder(ChatClient.builder(this.openAiChatModel))
|
||||
.numberOfQueries(4)
|
||||
.build();
|
||||
|
||||
@@ -75,7 +77,7 @@ class MultiQueryExpanderIT {
|
||||
void whenExpanderWithOriginalQueryIncluded() {
|
||||
Query query = new Query("What is the weather in Rome?");
|
||||
QueryExpander queryExpander = MultiQueryExpander.builder()
|
||||
.chatClientBuilder(ChatClient.builder(openAiChatModel))
|
||||
.chatClientBuilder(ChatClient.builder(this.openAiChatModel))
|
||||
.numberOfQueries(3)
|
||||
.includeOriginal(true)
|
||||
.build();
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests.rag.analysis.query.transformation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.integration.tests.TestApplication;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
@@ -44,7 +46,7 @@ class TranslationQueryTransformerIT {
|
||||
void whenTransformerWithDefaults() {
|
||||
Query query = new Query("Hvad er Danmarks hovedstad?");
|
||||
QueryTransformer queryTransformer = TranslationQueryTransformer.builder()
|
||||
.chatClientBuilder(ChatClient.builder(openAiChatModel))
|
||||
.chatClientBuilder(ChatClient.builder(this.openAiChatModel))
|
||||
.targetLanguage("english")
|
||||
.build();
|
||||
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests.rag.augmentation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.integration.tests.TestApplication;
|
||||
import org.springframework.ai.openai.OpenAiChatModel;
|
||||
@@ -26,8 +30,6 @@ import org.springframework.ai.rag.augmentation.QueryAugmentor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,7 @@ class ContextualQueryAugmentorIT {
|
||||
"Iorek loved to explore the snowy landscape and dreamt of one day going on an adventure around the North Pole."));
|
||||
|
||||
Query augmentedQuery = queryAugmentor.augment(query, documents);
|
||||
String response = openAiChatModel.call(augmentedQuery.text());
|
||||
String response = this.openAiChatModel.call(augmentedQuery.text());
|
||||
|
||||
assertThat(response).isNotEmpty();
|
||||
System.out.println(response);
|
||||
@@ -66,7 +68,7 @@ class ContextualQueryAugmentorIT {
|
||||
Query query = new Query("What is Iorek's dream?");
|
||||
List<Document> documents = List.of();
|
||||
Query augmentedQuery = queryAugmentor.augment(query, documents);
|
||||
String response = openAiChatModel.call(augmentedQuery.text());
|
||||
String response = this.openAiChatModel.call(augmentedQuery.text());
|
||||
|
||||
assertThat(response).isNotEmpty();
|
||||
System.out.println(response);
|
||||
@@ -79,7 +81,7 @@ class ContextualQueryAugmentorIT {
|
||||
Query query = new Query("What is Iorek's dream?");
|
||||
List<Document> documents = List.of();
|
||||
Query augmentedQuery = queryAugmentor.augment(query, documents);
|
||||
String response = openAiChatModel.call(augmentedQuery.text());
|
||||
String response = this.openAiChatModel.call(augmentedQuery.text());
|
||||
|
||||
assertThat(response).isNotEmpty();
|
||||
System.out.println(response);
|
||||
|
||||
@@ -13,12 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.integration.tests.rag.retrieval.search;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.integration.tests.TestApplication;
|
||||
import org.springframework.ai.rag.Query;
|
||||
@@ -29,9 +34,6 @@ import org.springframework.ai.vectorstore.filter.Filter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.ai.vectorstore.filter.Filter.ExpressionType.EQ;
|
||||
|
||||
@@ -64,18 +66,18 @@ class VectorStoreDocumentRetrieverIT {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
pgVectorStore.add(List.copyOf(documents.values()));
|
||||
this.pgVectorStore.add(List.copyOf(documents.values()));
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
pgVectorStore.delete(documents.values().stream().map(Document::getId).toList());
|
||||
this.pgVectorStore.delete(documents.values().stream().map(Document::getId).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void withFilter() {
|
||||
DocumentRetriever documentRetriever = VectorStoreDocumentRetriever.builder()
|
||||
.vectorStore(pgVectorStore)
|
||||
.vectorStore(this.pgVectorStore)
|
||||
.similarityThreshold(0.50)
|
||||
.topK(3)
|
||||
.filterExpression(
|
||||
@@ -95,7 +97,7 @@ class VectorStoreDocumentRetrieverIT {
|
||||
@Test
|
||||
void withNoFilter() {
|
||||
DocumentRetriever documentRetriever = VectorStoreDocumentRetriever.builder()
|
||||
.vectorStore(pgVectorStore)
|
||||
.vectorStore(this.pgVectorStore)
|
||||
.similarityThreshold(0.50)
|
||||
.topK(3)
|
||||
.build();
|
||||
|
||||
@@ -32,5 +32,7 @@
|
||||
<suppress files="BaseOCIGenAITest.java" checks="HideUtilityClassConstructor"/>
|
||||
<suppress files="OpenAiChatModelResponseFormatIT.java" checks="RegexpSinglelineJava"/>
|
||||
<suppress files="MethodFunctionCallbackTests.java" checks="RegexpSinglelineJava"/>
|
||||
<suppress files="ClientIT.java" checks="RegexpSinglelineJava"/>
|
||||
|
||||
|
||||
</suppressions>
|
||||
|
||||
Reference in New Issue
Block a user