Skip to content

FR: Support Automatic Function Calling (AFC) with non-static instance methods #807

@vorburger

Description

@vorburger

Is your feature request related to a problem? Please describe.*

It would be neat if we made it possible for Automatic Function Calling (AFC) to also work with non-static instance methods, so that (something like) this would work, note how getCurrentWeather is not static here:

public class GenerateContentWithFunctionCall {
  public String getCurrentWeather(String location, String unit) {
    return "The weather in " + location + " is " + "very nice.";
  }

  public static void main(String[] args) throws NoSuchMethodException {
    GenerateContentWithFunctionCall instance = new GenerateContentWithFunctionCall();

    Method method =
        GenerateContentWithFunctionCall.class.getMethod(
            "getCurrentWeather", String.class, String.class);

    GenerateContentConfig config =
        GenerateContentConfig.builder()
            .tools(Tool.builder().functions(method, instance))
            .build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions