Class FunctionExecutor


  • public class FunctionExecutor
    extends Object
    • Constructor Detail

      • FunctionExecutor

        public FunctionExecutor()
      • FunctionExecutor

        public FunctionExecutor​(List<FunctionDef> functions)
    • Method Detail

      • getToolFunctions

        public List<Tool> getToolFunctions()
      • getToolFunctions

        public List<Tool> getToolFunctions​(Object toolChoice)
      • 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.