Skip to content

Support for declarative build function callbacks in the Spring container #1105

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

Closed

Conversation

KAMO030
Copy link
Contributor

@KAMO030 KAMO030 commented Jul 24, 2024

  • add FunctionCallbackMethodProcessor to support parsing.
  • add the FunctionCalling annotation to declare
  • add FunctionCallbackMethodProcessorIT as test

Dependent on #1099

define:

public  class FunctionCallConfig {
		@FunctionCalling(name = "dateTime", description = "get the current date and time")
		public String dateTime(String location) {
			return location + " dateTime:" + LocalDateTime.now();
		}
}

use:

client.prompt().user("What is the time in New York?").functions("dateTime").call().content();

KAMO030 added 2 commits July 24, 2024 12:36
-- add FunctionCallbackMethodProcessor to support parsing.
-- add the FunctionCalling annotation to declare
-- add FunctionCallbackMethodProcessorIT as test

Dependent on spring-projects#1099
@csterwa csterwa mentioned this pull request Sep 12, 2024
10 tasks
@ThomasVitale
Copy link
Contributor

ThomasVitale commented Jan 27, 2025

Thanks for your PR. Declarative tool definition via annotation has been introduced in #2064. Does that handle your use case?

Example:

class MyTools {

    @Tool(description = "Get the list of books written by the given author available in the library")
    List<Book> booksByAuthor(String author) {
        return bookService.getBooksByAuthor(new Author(author));
    }

}
@GetMapping("/chat")
String chat(String authorName) {
    return chatClient.prompt()
            .user("What books written by %s are available in the library?".formatted(authorName))
            .tools(myTools)
            .call()
            .content();
}

@ilayaperumalg
Copy link
Member

@KAMO030 Please re-open this if you still see the issue and need help. Thanks!

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

Successfully merging this pull request may close these issues.

4 participants