Skip to content

Commit 78a58a1

Browse files
committed
Update commons logging for the latest changes
1 parent 8057b49 commit 78a58a1

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/proxy/DeepSeekWithOpenAiChatModelIT.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2828
import org.junit.jupiter.params.ParameterizedTest;
2929
import org.junit.jupiter.params.provider.ValueSource;
30-
import org.slf4j.Logger;
31-
import org.slf4j.LoggerFactory;
3230
import reactor.core.publisher.Flux;
3331

3432
import org.springframework.ai.chat.client.ChatClient;
@@ -56,6 +54,7 @@
5654
import org.springframework.context.annotation.Bean;
5755
import org.springframework.core.convert.support.DefaultConversionService;
5856
import org.springframework.core.io.Resource;
57+
import org.springframework.core.log.LogAccessor;
5958

6059
import static org.assertj.core.api.Assertions.assertThat;
6160

@@ -73,7 +72,7 @@
7372
@Disabled("Requires DeepSeek credits")
7473
class DeepSeekWithOpenAiChatModelIT {
7574

76-
private static final Logger logger = LoggerFactory.getLogger(DeepSeekWithOpenAiChatModelIT.class);
75+
private static final LogAccessor logger = new LogAccessor(DeepSeekWithOpenAiChatModelIT.class);
7776

7877
private static final String DEEPSEEK_BASE_URL = "https://api.deepseek.com";
7978

@@ -265,7 +264,7 @@ void functionCallTest() {
265264

266265
ChatResponse response = this.chatModel.call(new Prompt(messages, promptOptions));
267266

268-
logger.info("Response: {}", response);
267+
logger.info("Response: " + response);
269268

270269
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
271270
}
@@ -297,7 +296,7 @@ void streamFunctionCallTest() {
297296
.map(Generation::getOutput)
298297
.map(AssistantMessage::getText)
299298
.collect(Collectors.joining());
300-
logger.info("Response: {}", content);
299+
logger.info("Response: " + content);
301300

302301
assertThat(content).contains("30", "10", "15");
303302
}

spring-ai-core/src/main/java/org/springframework/ai/tool/execution/DefaultToolCallResultConverter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
package org.springframework.ai.tool.execution;
1818

19-
import org.slf4j.Logger;
20-
import org.slf4j.LoggerFactory;
19+
import java.lang.reflect.Type;
20+
21+
import org.apache.commons.logging.LogFactory;
22+
2123
import org.springframework.ai.util.json.JsonParser;
24+
import org.springframework.core.log.LogAccessor;
2225
import org.springframework.lang.Nullable;
2326

24-
import java.lang.reflect.Type;
25-
2627
/**
2728
* A default implementation of {@link ToolCallResultConverter}.
2829
*
@@ -31,7 +32,7 @@
3132
*/
3233
public final class DefaultToolCallResultConverter implements ToolCallResultConverter {
3334

34-
private static final Logger logger = LoggerFactory.getLogger(DefaultToolCallResultConverter.class);
35+
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(DefaultToolCallResultConverter.class));
3536

3637
@Override
3738
public String apply(@Nullable Object result, @Nullable Type returnType) {

spring-ai-core/src/main/java/org/springframework/ai/tool/function/FunctionToolCallback.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616

1717
package org.springframework.ai.tool.function;
1818

19-
import org.slf4j.Logger;
20-
import org.slf4j.LoggerFactory;
19+
import java.lang.reflect.Type;
20+
import java.util.function.BiFunction;
21+
import java.util.function.Consumer;
22+
import java.util.function.Function;
23+
import java.util.function.Supplier;
24+
25+
import org.apache.commons.logging.LogFactory;
26+
2127
import org.springframework.ai.chat.model.ToolContext;
2228
import org.springframework.ai.tool.ToolCallback;
2329
import org.springframework.ai.tool.definition.ToolDefinition;
@@ -28,16 +34,11 @@
2834
import org.springframework.ai.util.json.JsonParser;
2935
import org.springframework.ai.util.json.JsonSchemaGenerator;
3036
import org.springframework.core.ParameterizedTypeReference;
37+
import org.springframework.core.log.LogAccessor;
3138
import org.springframework.lang.Nullable;
3239
import org.springframework.util.Assert;
3340
import org.springframework.util.StringUtils;
3441

35-
import java.lang.reflect.Type;
36-
import java.util.function.BiFunction;
37-
import java.util.function.Consumer;
38-
import java.util.function.Function;
39-
import java.util.function.Supplier;
40-
4142
/**
4243
* A {@link ToolCallback} implementation to invoke functions as tools.
4344
*
@@ -46,7 +47,7 @@
4647
*/
4748
public class FunctionToolCallback<I, O> implements ToolCallback {
4849

49-
private static final Logger logger = LoggerFactory.getLogger(FunctionToolCallback.class);
50+
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(FunctionToolCallback.class));
5051

5152
private static final ToolCallResultConverter DEFAULT_RESULT_CONVERTER = new DefaultToolCallResultConverter();
5253

@@ -94,12 +95,12 @@ public String call(String toolInput) {
9495
public String call(String toolInput, @Nullable ToolContext toolContext) {
9596
Assert.hasText(toolInput, "toolInput cannot be null or empty");
9697

97-
logger.debug("Starting execution of tool: {}", toolDefinition.name());
98+
logger.debug("Starting execution of tool: " + toolDefinition.name());
9899

99100
I request = JsonParser.fromJson(toolInput, toolInputType);
100101
O response = toolFunction.apply(request, toolContext);
101102

102-
logger.debug("Successful execution of tool: {}", toolDefinition.name());
103+
logger.debug("Successful execution of tool: " + toolDefinition.name());
103104

104105
return toolCallResultConverter.apply(response, null);
105106
}

spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/FunctionToolCallbackTests.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
package org.springframework.ai.integration.tests.tool;
1818

19+
import java.util.List;
20+
import java.util.function.Consumer;
21+
import java.util.function.Function;
22+
23+
import org.apache.commons.logging.LogFactory;
1924
import org.junit.jupiter.api.Test;
2025
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
21-
import org.slf4j.Logger;
22-
import org.slf4j.LoggerFactory;
26+
2327
import org.springframework.ai.chat.client.ChatClient;
2428
import org.springframework.ai.integration.tests.TestApplication;
2529
import org.springframework.ai.integration.tests.tool.domain.Author;
@@ -33,10 +37,7 @@
3337
import org.springframework.context.annotation.Configuration;
3438
import org.springframework.context.annotation.Description;
3539
import org.springframework.context.annotation.Import;
36-
37-
import java.util.List;
38-
import java.util.function.Consumer;
39-
import java.util.function.Function;
40+
import org.springframework.core.log.LogAccessor;
4041

4142
import static org.assertj.core.api.Assertions.assertThat;
4243

@@ -52,7 +53,7 @@ public class FunctionToolCallbackTests {
5253

5354
// @formatter:off
5455

55-
private static final Logger logger = LoggerFactory.getLogger(FunctionToolCallbackTests.class);
56+
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(FunctionToolCallbackTests.class));
5657

5758
@Autowired
5859
OpenAiChatModel openAiChatModel;
@@ -105,7 +106,7 @@ void chatVoidOutputFromCallback() {
105106
.prompt()
106107
.user("Welcome %s to the library".formatted("James Bond"))
107108
.toolCallbacks(FunctionToolCallback.builder("welcomeUser", (user) -> {
108-
logger.info("CALLBACK - Welcoming {} to the library", ((User) user).name());
109+
logger.info("CALLBACK - Welcoming "+ ((User) user).name() +" to the library");
109110
})
110111
.description("Welcome a specific user to the library")
111112
.inputType(User.class)
@@ -133,7 +134,7 @@ void chatSingleFromBean() {
133134
@Test
134135
void chatSingleFromCallback() {
135136
Function<Author, List<Book>> function = author -> {
136-
logger.info("CALLBACK - Getting books by author: {}", author.name());
137+
logger.info("CALLBACK - Getting books by author: "+ author.name());
137138
return new BookService().getBooksByAuthor(author);
138139
};
139140
var content = ChatClient.builder(this.openAiChatModel)
@@ -167,7 +168,7 @@ void chatListFromBean() {
167168
@Test
168169
void chatListFromCallback() {
169170
Function<Books, List<Author>> function = books -> {
170-
logger.info("CALLBACK - Getting authors by books: {}", books.books().stream().map(Book::title).toList());
171+
logger.info("CALLBACK - Getting authors by books: "+ books.books().stream().map(Book::title).toList());
171172
return new BookService().getAuthorsByBook(books.books());
172173
};
173174
var content = ChatClient.builder(this.openAiChatModel)
@@ -194,7 +195,7 @@ static class Tools {
194195

195196
public static final String WELCOME_USER = "welcomeUser";
196197

197-
private static final Logger logger = LoggerFactory.getLogger(Tools.class);
198+
private static final LogAccessor logger = new LogAccessor(Tools.class);
198199

199200
private final BookService bookService = new BookService();
200201

@@ -207,14 +208,14 @@ Consumer<Void> welcome() {
207208
@Bean(WELCOME_USER)
208209
@Description("Welcome a specific user to the library")
209210
Consumer<User> welcomeUser() {
210-
return user -> logger.info("Welcoming {} to the library", user.name());
211+
return user -> logger.info("Welcoming "+ user.name() +" to the library");
211212
}
212213

213214
@Bean(BOOKS_BY_AUTHOR)
214215
@Description("Get the list of books written by the given author available in the library")
215216
Function<Author, List<Book>> booksByAuthor() {
216217
return author -> {
217-
logger.info("Getting books by author: {}", author.name());
218+
logger.info("Getting books by author: "+ author.name());
218219
return bookService.getBooksByAuthor(author);
219220
};
220221
}
@@ -223,7 +224,7 @@ Function<Author, List<Book>> booksByAuthor() {
223224
@Description("Get the list of authors who wrote the given books available in the library")
224225
Function<Books, List<Author>> authorsByBooks() {
225226
return books -> {
226-
logger.info("Getting authors by books: {}", books.books().stream().map(Book::title).toList());
227+
logger.info("Getting authors by books: "+ books.books().stream().map(Book::title).toList());
227228
return bookService.getAuthorsByBook(books.books());
228229
};
229230
}

spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616

1717
package org.springframework.ai.integration.tests.tool;
1818

19+
import java.util.List;
20+
21+
import org.apache.commons.logging.LogFactory;
1922
import org.junit.jupiter.api.Test;
2023
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
21-
import org.slf4j.Logger;
22-
import org.slf4j.LoggerFactory;
24+
import reactor.core.publisher.Flux;
25+
2326
import org.springframework.ai.chat.messages.Message;
2427
import org.springframework.ai.chat.messages.ToolResponseMessage;
2528
import org.springframework.ai.chat.messages.UserMessage;
@@ -38,9 +41,7 @@
3841
import org.springframework.ai.tool.annotation.Tool;
3942
import org.springframework.beans.factory.annotation.Autowired;
4043
import org.springframework.boot.test.context.SpringBootTest;
41-
import reactor.core.publisher.Flux;
42-
43-
import java.util.List;
44+
import org.springframework.core.log.LogAccessor;
4445

4546
import static org.assertj.core.api.Assertions.assertThat;
4647

@@ -143,13 +144,13 @@ private void runExplicitToolCallingExecutionWithOptionsStream(ChatOptions chatOp
143144

144145
static class Tools {
145146

146-
private static final Logger logger = LoggerFactory.getLogger(Tools.class);
147+
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(Tools.class));
147148

148149
private final BookService bookService = new BookService();
149150

150151
@Tool(description = "Get the list of books written by the given author available in the library")
151152
List<Book> booksByAuthor(String author) {
152-
logger.info("Getting books by author: {}", author);
153+
logger.info("Getting books by author: " + author);
153154
return bookService.getBooksByAuthor(new Author(author));
154155
}
155156

vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@
2525
import com.fasterxml.jackson.core.JsonProcessingException;
2626
import com.fasterxml.jackson.databind.ObjectMapper;
2727
import com.fasterxml.jackson.databind.json.JsonMapper;
28-
import org.slf4j.Logger;
29-
import org.slf4j.LoggerFactory;
3028

3129
import org.springframework.ai.chroma.vectorstore.ChromaApi.AddEmbeddingsRequest;
3230
import org.springframework.ai.chroma.vectorstore.ChromaApi.DeleteEmbeddingsRequest;
3331
import org.springframework.ai.chroma.vectorstore.ChromaApi.Embedding;
3432
import org.springframework.ai.document.Document;
3533
import org.springframework.ai.document.DocumentMetadata;
36-
import org.springframework.ai.embedding.BatchingStrategy;
3734
import org.springframework.ai.embedding.EmbeddingModel;
3835
import org.springframework.ai.embedding.EmbeddingOptionsBuilder;
39-
import org.springframework.ai.embedding.TokenCountBatchingStrategy;
4036
import org.springframework.ai.observation.conventions.VectorStoreProvider;
4137
import org.springframework.ai.util.JacksonUtils;
4238
import org.springframework.ai.vectorstore.AbstractVectorStoreBuilder;
@@ -47,6 +43,7 @@
4743
import org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore;
4844
import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext;
4945
import org.springframework.beans.factory.InitializingBean;
46+
import org.springframework.core.log.LogAccessor;
5047
import org.springframework.lang.NonNull;
5148
import org.springframework.lang.Nullable;
5249
import org.springframework.util.Assert;
@@ -84,7 +81,7 @@ public class ChromaVectorStore extends AbstractObservationVectorStore implements
8481

8582
private boolean initialized = false;
8683

87-
private static final Logger logger = LoggerFactory.getLogger(ChromaVectorStore.class);
84+
private static final LogAccessor logger = new LogAccessor(ChromaVectorStore.class);
8885

8986
/**
9087
* @param builder {@link VectorStore.Builder} for chroma vector store
@@ -176,13 +173,13 @@ protected void doDelete(Filter.Expression expression) {
176173

177174
Map<String, Object> whereClause = this.chromaApi.where(whereClauseStr);
178175

179-
logger.debug("Deleting with where clause: {}", whereClause);
176+
logger.debug("Deleting with where clause: " + whereClause);
180177

181178
DeleteEmbeddingsRequest deleteRequest = new DeleteEmbeddingsRequest(null, whereClause);
182179
this.chromaApi.deleteEmbeddings(this.collectionId, deleteRequest);
183180
}
184181
catch (Exception e) {
185-
logger.error("Failed to delete documents by filter: {}", e.getMessage(), e);
182+
logger.error(e, "Failed to delete documents by filter: " + e.getMessage());
186183
throw new IllegalStateException("Failed to delete documents by filter", e);
187184
}
188185
}

0 commit comments

Comments
 (0)