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

Advancing Tool Support - Part 2 #2085

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ThomasVitale
Copy link
Contributor

  • Enhanced support for functions as tools via FunctionToolCallback (deprecating the existing FunctionInvokingFunctionCallback).
  • Aligned JSON Schema generation and parsing logic between function-based and method-based tools.
  • Deprecated previous client-side function calling APIs.
  • Included AOT configuration for Tool-annotated methods in Spring beans.

Relates to gh-2049

* Enhanced support for functions as tools via FunctionToolCallback (deprecating the existing FunctionInvokingFunctionCallback).
* Aligned JSON Schema generation and parsing logic between function-based and method-based tools.
* Deprecated previous client-side function calling APIs.
* Included AOT configuration for Tool-annotated methods in Spring beans.

Relates to spring-projectsgh-2049

Signed-off-by: Thomas Vitale <[email protected]>
* @author Thomas Vitale
* @since 1.0.0
*/
class ToolBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdeleuze I followed your tips and implemented this BeanRegistrationAotProcessor to process Spring beans which contain @Tool-annotated methods. I included unit tests and also tested it in a GraalVM-based app here: https://github.com/ThomasVitale/llm-apps-java-spring-ai/tree/main/patterns/tool-calling/tool-calling-openai

return builder(name, function);
}

public static class Builder<I, O> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept a similar API to the one in FunctionCallback.Builder so to make it straightforward to migrate to this new Builder.

@tzolov tzolov self-assigned this Jan 20, 2025
@tzolov tzolov added this to the 1.0.0-M6 milestone Jan 20, 2025
@NonNullFields
package org.springframework.ai.aot;

import org.springframework.lang.NonNullApi;

This comment was marked as resolved.

Copy link
Contributor Author

@ThomasVitale ThomasVitale Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spring Framework is migrating to JSpecify in the new generation (version 7). When that happens, I imagine the other Spring projects (including Spring AI) will follow. The current generation is still Spring Framework 6, where JSpecify is not adopted.

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.

3 participants