Class FunctionExecutor
- java.lang.Object
-
- io.github.sashirestela.openai.common.function.FunctionExecutor
-
public class FunctionExecutor extends Object
-
-
Constructor Summary
Constructors Constructor Description FunctionExecutor()FunctionExecutor(List<FunctionDef> functions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenrollFunction(FunctionDef function)voidenrollFunctions(List<FunctionDef> functions)<T> Texecute(FunctionCall functionCall)<T> Texecute(String name, String arguments)<R> List<R>executeAll(List<ToolCall> toolCalls, BiFunction<String,String,R> toolOutputItem)Run the 'execute()' method for a list of FunctionDefs.List<Tool>getToolFunctions()List<Tool>getToolFunctions(Object toolChoice)
-
-
-
Constructor Detail
-
FunctionExecutor
public FunctionExecutor()
-
FunctionExecutor
public FunctionExecutor(List<FunctionDef> functions)
-
-
Method Detail
-
enrollFunction
public void enrollFunction(FunctionDef function)
-
enrollFunctions
public void enrollFunctions(List<FunctionDef> functions)
-
execute
public <T> T execute(FunctionCall functionCall)
-
executeAll
public <R> List<R> executeAll(List<ToolCall> toolCalls, BiFunction<String,String,R> toolOutputItem)
Run the 'execute()' method for a list of FunctionDefs.- Type Parameters:
R- Specific type to gather the result. ToolMessage for ChatCompletion or ToolOutput for Assistants.- Parameters:
toolCalls- Response from the model to call functions.toolOutputItem- BiFunction with two arguments: 'toolCallId' and 'result'. Returns a new R object with those arguments.- Returns:
- List of R objects.
-
-