Skip to content

Add support for Consumer and Supplier function callbacks #1718

@tzolov

Description

@tzolov

Currently, Spring AI's function callbacks only support Function and BiFunction interfaces.
We should extend support to other common functional interfaces, specifically Consumer and Supplier
and support the semantically equivalent Function<Void,O> and Function<I, Void>.

Example Usage:

@Bean
@Description("Turn light on in a room")
public Consumer<LightInfo> turnLightConsumer() {
    return (LightInfo lightInfo) -> {
        // Handle light control
    };
}

@Bean
@Description("Get room status")
public Supplier<String> getRoomStatus() {
    return () -> {
        // Return room status
    };
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions