spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/index.html
Apache License 2.0
3.32k stars 850 forks source link

There is no usable working Builder for a FunctionCallback #1768

Open fedecompa opened 2 days ago

fedecompa commented 2 days ago

Bug description The class DefaultFunctionCallbackBuilder has a field private String inputTypeSchema, but there is no .build() method to costruct an instance of a FunctionCallback defined at runtime. The class FunctionInvokingFunctionCallback has not public constructor.

Environment Spring AI version: 1.0.0-SNAPSHOT Java version: 17

Expected behavior I need a public usable Builder where I can set the name, the description and the JSON schema in string format (and not necessarily a Class) and returning an instance of FunctionCallback.

    DefaultFunctionCallbackBuilder defaultFunctionCallbackBuilder = new DefaultFunctionCallbackBuilder();
    FunctionCallback.Builder builder = defaultFunctionCallbackBuilder
            .description(description).inputTypeSchema(parameters)
            .schemaType(FunctionCallbackContext.SchemaType.JSON_SCHEMA);
    FunctionCallback functionCallback = builder.build();    // MISSING !
    ChatOptions promptOptions = AzureOpenAiChatOptions.builder()
            .withResponseFormat(AzureOpenAiResponseFormat.JSON)
            .withFunctionCallbacks(List.of()).build();