diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/proxy/DeepSeekWithOpenAiChatModelIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/proxy/DeepSeekWithOpenAiChatModelIT.java index fe00a6a69..88f153c01 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/proxy/DeepSeekWithOpenAiChatModelIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/proxy/DeepSeekWithOpenAiChatModelIT.java @@ -27,8 +27,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; import org.springframework.ai.chat.client.ChatClient; @@ -56,6 +54,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.io.Resource; +import org.springframework.core.log.LogAccessor; import static org.assertj.core.api.Assertions.assertThat; @@ -73,7 +72,7 @@ import static org.assertj.core.api.Assertions.assertThat; @Disabled("Requires DeepSeek credits") class DeepSeekWithOpenAiChatModelIT { - private static final Logger logger = LoggerFactory.getLogger(DeepSeekWithOpenAiChatModelIT.class); + private static final LogAccessor logger = new LogAccessor(DeepSeekWithOpenAiChatModelIT.class); private static final String DEEPSEEK_BASE_URL = "https://api.deepseek.com"; @@ -265,7 +264,7 @@ class DeepSeekWithOpenAiChatModelIT { ChatResponse response = this.chatModel.call(new Prompt(messages, promptOptions)); - logger.info("Response: {}", response); + logger.info("Response: " + response); assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15"); } @@ -297,7 +296,7 @@ class DeepSeekWithOpenAiChatModelIT { .map(Generation::getOutput) .map(AssistantMessage::getText) .collect(Collectors.joining()); - logger.info("Response: {}", content); + logger.info("Response: " + content); assertThat(content).contains("30", "10", "15"); } diff --git a/spring-ai-core/src/main/java/org/springframework/ai/tool/execution/DefaultToolCallResultConverter.java b/spring-ai-core/src/main/java/org/springframework/ai/tool/execution/DefaultToolCallResultConverter.java index a43dcd237..577acbae9 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/tool/execution/DefaultToolCallResultConverter.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/tool/execution/DefaultToolCallResultConverter.java @@ -16,13 +16,14 @@ package org.springframework.ai.tool.execution; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.ai.util.json.JsonParser; -import org.springframework.lang.Nullable; - import java.lang.reflect.Type; +import org.apache.commons.logging.LogFactory; + +import org.springframework.ai.util.json.JsonParser; +import org.springframework.core.log.LogAccessor; +import org.springframework.lang.Nullable; + /** * A default implementation of {@link ToolCallResultConverter}. * @@ -31,7 +32,7 @@ import java.lang.reflect.Type; */ public final class DefaultToolCallResultConverter implements ToolCallResultConverter { - private static final Logger logger = LoggerFactory.getLogger(DefaultToolCallResultConverter.class); + private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(DefaultToolCallResultConverter.class)); @Override public String apply(@Nullable Object result, @Nullable Type returnType) { diff --git a/spring-ai-core/src/main/java/org/springframework/ai/tool/function/FunctionToolCallback.java b/spring-ai-core/src/main/java/org/springframework/ai/tool/function/FunctionToolCallback.java index e708efa53..6d5936b4a 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/tool/function/FunctionToolCallback.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/tool/function/FunctionToolCallback.java @@ -16,8 +16,14 @@ package org.springframework.ai.tool.function; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.lang.reflect.Type; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import org.apache.commons.logging.LogFactory; + import org.springframework.ai.chat.model.ToolContext; import org.springframework.ai.tool.ToolCallback; import org.springframework.ai.tool.definition.ToolDefinition; @@ -28,16 +34,11 @@ import org.springframework.ai.tool.util.ToolUtils; import org.springframework.ai.util.json.JsonParser; import org.springframework.ai.util.json.JsonSchemaGenerator; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.log.LogAccessor; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.StringUtils; -import java.lang.reflect.Type; -import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - /** * A {@link ToolCallback} implementation to invoke functions as tools. * @@ -46,7 +47,7 @@ import java.util.function.Supplier; */ public class FunctionToolCallback implements ToolCallback { - private static final Logger logger = LoggerFactory.getLogger(FunctionToolCallback.class); + private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(FunctionToolCallback.class)); private static final ToolCallResultConverter DEFAULT_RESULT_CONVERTER = new DefaultToolCallResultConverter(); @@ -94,12 +95,12 @@ public class FunctionToolCallback implements ToolCallback { public String call(String toolInput, @Nullable ToolContext toolContext) { Assert.hasText(toolInput, "toolInput cannot be null or empty"); - logger.debug("Starting execution of tool: {}", toolDefinition.name()); + logger.debug("Starting execution of tool: " + toolDefinition.name()); I request = JsonParser.fromJson(toolInput, toolInputType); O response = toolFunction.apply(request, toolContext); - logger.debug("Successful execution of tool: {}", toolDefinition.name()); + logger.debug("Successful execution of tool: " + toolDefinition.name()); return toolCallResultConverter.apply(response, null); } diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java index 3cdeb44a9..244baa0be 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java @@ -16,10 +16,14 @@ package org.springframework.ai.integration.tests.tool; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; + +import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.integration.tests.TestApplication; import org.springframework.ai.integration.tests.tool.domain.Author; @@ -33,10 +37,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Description; import org.springframework.context.annotation.Import; - -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; +import org.springframework.core.log.LogAccessor; import static org.assertj.core.api.Assertions.assertThat; @@ -52,7 +53,7 @@ public class FunctionToolCallbackTests { // @formatter:off - private static final Logger logger = LoggerFactory.getLogger(FunctionToolCallbackTests.class); + private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(FunctionToolCallbackTests.class)); @Autowired OpenAiChatModel openAiChatModel; @@ -105,7 +106,7 @@ public class FunctionToolCallbackTests { .prompt() .user("Welcome %s to the library".formatted("James Bond")) .toolCallbacks(FunctionToolCallback.builder("welcomeUser", (user) -> { - logger.info("CALLBACK - Welcoming {} to the library", ((User) user).name()); + logger.info("CALLBACK - Welcoming "+ ((User) user).name() +" to the library"); }) .description("Welcome a specific user to the library") .inputType(User.class) @@ -133,7 +134,7 @@ public class FunctionToolCallbackTests { @Test void chatSingleFromCallback() { Function> function = author -> { - logger.info("CALLBACK - Getting books by author: {}", author.name()); + logger.info("CALLBACK - Getting books by author: "+ author.name()); return new BookService().getBooksByAuthor(author); }; var content = ChatClient.builder(this.openAiChatModel) @@ -167,7 +168,7 @@ public class FunctionToolCallbackTests { @Test void chatListFromCallback() { Function> function = books -> { - logger.info("CALLBACK - Getting authors by books: {}", books.books().stream().map(Book::title).toList()); + logger.info("CALLBACK - Getting authors by books: "+ books.books().stream().map(Book::title).toList()); return new BookService().getAuthorsByBook(books.books()); }; var content = ChatClient.builder(this.openAiChatModel) @@ -194,7 +195,7 @@ public class FunctionToolCallbackTests { public static final String WELCOME_USER = "welcomeUser"; - private static final Logger logger = LoggerFactory.getLogger(Tools.class); + private static final LogAccessor logger = new LogAccessor(Tools.class); private final BookService bookService = new BookService(); @@ -207,14 +208,14 @@ public class FunctionToolCallbackTests { @Bean(WELCOME_USER) @Description("Welcome a specific user to the library") Consumer welcomeUser() { - return user -> logger.info("Welcoming {} to the library", user.name()); + return user -> logger.info("Welcoming "+ user.name() +" to the library"); } @Bean(BOOKS_BY_AUTHOR) @Description("Get the list of books written by the given author available in the library") Function> booksByAuthor() { return author -> { - logger.info("Getting books by author: {}", author.name()); + logger.info("Getting books by author: "+ author.name()); return bookService.getBooksByAuthor(author); }; } @@ -223,7 +224,7 @@ public class FunctionToolCallbackTests { @Description("Get the list of authors who wrote the given books available in the library") Function> authorsByBooks() { return books -> { - logger.info("Getting authors by books: {}", books.books().stream().map(Book::title).toList()); + logger.info("Getting authors by books: "+ books.books().stream().map(Book::title).toList()); return bookService.getAuthorsByBook(books.books()); }; } diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java index 94084dd5b..34fc1887f 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java @@ -16,10 +16,13 @@ package org.springframework.ai.integration.tests.tool; +import java.util.List; + +import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import reactor.core.publisher.Flux; + import org.springframework.ai.chat.messages.Message; import org.springframework.ai.chat.messages.ToolResponseMessage; import org.springframework.ai.chat.messages.UserMessage; @@ -38,9 +41,7 @@ import org.springframework.ai.tool.ToolCallbacks; import org.springframework.ai.tool.annotation.Tool; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import reactor.core.publisher.Flux; - -import java.util.List; +import org.springframework.core.log.LogAccessor; import static org.assertj.core.api.Assertions.assertThat; @@ -143,13 +144,13 @@ public class ToolCallingManagerTests { static class Tools { - private static final Logger logger = LoggerFactory.getLogger(Tools.class); + private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(Tools.class)); private final BookService bookService = new BookService(); @Tool(description = "Get the list of books written by the given author available in the library") List booksByAuthor(String author) { - logger.info("Getting books by author: {}", author); + logger.info("Getting books by author: " + author); return bookService.getBooksByAuthor(new Author(author)); } diff --git a/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java b/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java index a8a600225..ca5ace322 100644 --- a/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java +++ b/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java @@ -25,18 +25,14 @@ import java.util.Optional; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.ai.chroma.vectorstore.ChromaApi.AddEmbeddingsRequest; import org.springframework.ai.chroma.vectorstore.ChromaApi.DeleteEmbeddingsRequest; import org.springframework.ai.chroma.vectorstore.ChromaApi.Embedding; import org.springframework.ai.document.Document; import org.springframework.ai.document.DocumentMetadata; -import org.springframework.ai.embedding.BatchingStrategy; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.EmbeddingOptionsBuilder; -import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.util.JacksonUtils; import org.springframework.ai.vectorstore.AbstractVectorStoreBuilder; @@ -47,6 +43,7 @@ import org.springframework.ai.vectorstore.filter.FilterExpressionConverter; import org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.log.LogAccessor; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -84,7 +81,7 @@ public class ChromaVectorStore extends AbstractObservationVectorStore implements private boolean initialized = false; - private static final Logger logger = LoggerFactory.getLogger(ChromaVectorStore.class); + private static final LogAccessor logger = new LogAccessor(ChromaVectorStore.class); /** * @param builder {@link VectorStore.Builder} for chroma vector store @@ -176,13 +173,13 @@ public class ChromaVectorStore extends AbstractObservationVectorStore implements Map whereClause = this.chromaApi.where(whereClauseStr); - logger.debug("Deleting with where clause: {}", whereClause); + logger.debug("Deleting with where clause: " + whereClause); DeleteEmbeddingsRequest deleteRequest = new DeleteEmbeddingsRequest(null, whereClause); this.chromaApi.deleteEmbeddings(this.collectionId, deleteRequest); } catch (Exception e) { - logger.error("Failed to delete documents by filter: {}", e.getMessage(), e); + logger.error(e, "Failed to delete documents by filter: " + e.getMessage()); throw new IllegalStateException("Failed to delete documents by filter", e); } }