Christian Tzolov 5f6b892eda Add function calling support to invoke methods with dynamic arguments and return values
This change enables more flexible integration between Spring AI and LLM function
calling capabilities while maintaining type safety and ease of use.

- Add new MethodFunctionCallback class to support method invocation via reflection
 - Supports both static and non-static method calls
 - Handles multiple parameter types including primitives, objects, collections
 - Supports empty parameters and empty response
 - Auto-generates JSON schema from method parameters
 - Special handling for ToolContext parameters
 - Builder pattern for easy configuration

- Add comprehensive unit tests for MethodFunctionCallback
- Add integration tests for MethodFunctionCallback with both Anthropic and OpenAI clients
- Add jackson-module-jsonSchema dependency
- Modify FunctionCallback to check for empty tool context

Testing coverage includes:
- Static method invocation scenarios
- Non-static method calls with various parameter types
- Void return type methods
- Complex parameter types (enums, records, lists)
- Tool context handling
- Error cases and validation

Add MethodFunctionCallback reference docs
2024-11-10 22:58:40 -05:00
2024-10-24 16:43:59 -04:00
2024-11-08 14:54:42 -05:00
2024-10-24 16:43:59 -04:00
2024-11-08 15:18:35 +00:00
2024-11-08 15:18:35 +00:00
2024-10-24 16:43:59 -04:00
2024-07-17 11:42:09 +02:00
2023-07-24 19:37:06 -04:00
2024-10-24 16:43:59 -04:00
2023-07-24 19:37:06 -04:00
2024-11-08 11:07:53 +01:00
2024-10-24 20:31:19 -04:00
2024-10-24 20:31:19 -04:00
2024-10-24 16:43:59 -04:00

Spring AI build status

The Spring AI project provides a Spring-friendly API and abstractions for developing AI applications.

Its goal is to apply to the AI domain Spring ecosystem design principles such as portability and modular design and promote using POJOs as the building blocks of an application to the AI domain.

spring-ai-integration-diagram-3

At its core, Spring AI addresses the fundamental challenge of AI integration: Connecting your enterprise Data and APIs with the AI Models.

For further information go to our Spring AI Reference Documentation.

The project draws inspiration from notable Python projects, such as LangChain and LlamaIndex, but Spring AI is not a direct port of those projects. The project was founded with the belief that the next wave of Generative AI applications will not be only for Python developers but will be ubiquitous across many programming languages.

This is a high level feature overview. You can find more details in the Reference Documentation

Breaking changes

  • Refer to the upgrade notes to see how to upgrade to 1.0.0.M1 or higher.

Getting Started

Please refer to the Getting Started Guide for instruction on adding your dependencies.

Cloning the repo

This repository contains large model files. To clone it you have to either:

  • Ignore the large files (won't affect the spring-ai behaviour) : GIT_LFS_SKIP_SMUDGE=1 git clone git@github.com:spring-projects/spring-ai.git.
  • Or install the Git Large File Storage before cloning the repo.

Building

To build with running unit tests

./mvnw clean package

To build including integration tests. Set API key environment variables for OpenAI and Azure OpenAI before running.

./mvnw clean verify -Pintegration-tests

To run a specific integration test allowing for up to two attempts to succeed. This is useful when a hosted service is not reliable or times out.

./mvnw -pl vector-stores/spring-ai-pgvector-store -Pintegration-tests -Dfailsafe.rerunFailingTestsCount=2 -Dit.test=PgVectorStoreIT verify

To build the docs

./mvnw -pl spring-ai-docs antora

The docs are then in the directory spring-ai-docs/target/antora/site/index.html

To reformat using the java-format plugin

./mvnw spring-javaformat:apply

To update the year on license headers using the license-maven-plugin

./mvnw license:update-file-header -Plicense

To check javadocs using the javadoc:javadoc

./mvnw javadoc:javadoc -Pjavadoc

To build with checkstyles enabled. Checkstyles are currently disabled, but you can enable them by doing the following:

./mvnw clean package -DskipTests -Ddisable.checks=false

Educational Resources

Spring AI blogs:

Code Examples

Workshops

Talks and Videos

Some selected videos. Search YouTube! for more.

  • Spring AI: Seamlessly Integrating AI into Your Enterprise Java Applications (2024 - Devoxx.be)
    Spring AI: Seamlessly Integrating AI into Your Enterprise Java Applications

  • Spring AI Is All You Need (2024 - GOTO Amsterdam)
    Watch Spring Tips video

  • Introducing Spring AI (2024 - Spring.IO)
    Introducing Spring AI

  • Spring AI at Spring.IO Keynotes (2024 - Spring.IO)
    Watch

  • Spring Tips: Spring AI
    Watch Spring Tips video

  • Overview of Spring AI @ Devoxx 2023
    Watch the Devoxx 2023 video
  • Introducing Spring AI - Add Generative AI to your Spring Applications
    Watch the video
  • Spring AI Introduction: Building AI Applications in Java with Spring
    Watch the video
Description
No description provided
Readme 87 MiB
Languages
Java 99.5%
Kotlin 0.3%