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 @@ -15,6 +15,7 @@
*/
package org.springframework.ai.tool;

import java.util.Collection;
import java.util.List;

import org.springframework.ai.model.function.FunctionCallback;
Expand Down Expand Up @@ -76,6 +77,19 @@ public StaticToolCallbackProvider(List<? extends FunctionCallback> toolCallbacks
this.toolCallbacks = toolCallbacks.toArray(new FunctionCallback[0]);
}

/**
* Constructs a new StaticToolCallbackProvider with the specified list of function
* callbacks. The list is converted to an array internally.
* @param toolCallbacks the list of function callbacks to be provided by this
* provider. Must not be null and must not contain null elements.
* @throws IllegalArgumentException if the toolCallbacks list is null or contains null
* elements
*/
public StaticToolCallbackProvider(Collection<? extends ToolCallback> toolCallbacks) {
Assert.noNullElements(toolCallbacks, "toolCallbacks cannot contain null elements");
this.toolCallbacks = toolCallbacks.toArray(new FunctionCallback[0]);
}

/**
* Returns the array of function callbacks held by this provider.
* @return an array containing all function callbacks provided during construction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.ai.tool;

import java.util.Collection;
import java.util.List;

import org.springframework.ai.model.function.FunctionCallback;
Expand All @@ -30,12 +31,23 @@ public interface ToolCallbackProvider {

FunctionCallback[] getToolCallbacks();

@Deprecated
public static ToolCallbackProvider from(List<? extends FunctionCallback> toolCallbacks) {
return new StaticToolCallbackProvider(toolCallbacks);
}

@Deprecated
public static ToolCallbackProvider from(FunctionCallback... toolCallbacks) {
return new StaticToolCallbackProvider(toolCallbacks);
}

static ToolCallbackProvider from(Collection<? extends ToolCallback> toolCallbacks) {
return new StaticToolCallbackProvider(toolCallbacks);
}

static ToolCallbackProvider from(ToolCallback... toolCallbacks) {
return new StaticToolCallbackProvider(toolCallbacks);
}


}