Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no usable working Builder for a FunctionCallback #1768

Closed
fedecompa opened this issue Nov 19, 2024 · 2 comments
Closed

There is no usable working Builder for a FunctionCallback #1768

fedecompa opened this issue Nov 19, 2024 · 2 comments
Milestone

Comments

@fedecompa
Copy link

fedecompa commented Nov 19, 2024

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(functionCallback)).build();
@markpollack
Copy link
Member

Some changes were made to the builder since we got to triage this issue.

You can use this style of the builder to achieve what you want now.

	FunctionCallback.builder().function("functionName", input -> "output").inputTypeSchema("my custom schema").description("my description").schemaType(FunctionCallback.SchemaType.JSON_SCHEMA);
	

Let us know if this solves your issue.

Thanks

@ilayaperumalg
Copy link
Member

Closing this as the support around FunctionCallback and the generic Tool support is being addressed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants