Skip to content
Closed
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 @@ -16,6 +16,9 @@

package org.springframework.ai.tool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.ai.chat.model.ToolContext;
import org.springframework.ai.tool.definition.ToolDefinition;
import org.springframework.ai.tool.metadata.ToolMetadata;
Expand All @@ -29,6 +32,8 @@
*/
public interface ToolCallback {

Logger logger = LoggerFactory.getLogger(ToolCallback.class);

/**
* Definition used by the AI model to determine when and how to call the tool.
*/
Expand All @@ -53,7 +58,9 @@ default ToolMetadata getToolMetadata() {
*/
default String call(String toolInput, @Nullable ToolContext toolContext) {
if (toolContext != null && !toolContext.getContext().isEmpty()) {
throw new UnsupportedOperationException("Tool context is not supported!");
logger.info("By default the tool context is not used, "
+ "override the method 'call(String toolInput, ToolContext toolcontext)' to support the use of tool context."
+ "Review the ToolCallback implementation for {}", getToolDefinition().name());
}
return call(toolInput);
}
Expand Down