This version is still in development and is not considered stable yet. For the latest snapshot version, please use Spring AI 1.0.0-SNAPSHOT!spring-doc.cn

Contribution Guidelines

Code Formatting and Javadoc

Before submitting a PR, please run the following commands to ensure proper formatting and Javadoc processingspring-doc.cn

./mvnw spring-javaformat:apply javadoc:javadoc -Pjavadoc

The -Pjavadoc is a profile that enables Javadoc processing so as to avoid a long build time when developing.spring-doc.cn

Contributing a New AI Model Implementation

This section outlines the steps for contributing a new AI model implementation. AI models vary significantly, with diverse inputs and outputs — from chat models that translate text input into text output, to text-to-image models that generate images from text descriptions. Complex models may even handle multiple types of input and output, such as combining text, images, and videos to produce mixed media output.spring-doc.cn

To contribute a new model, adhere to the following steps:spring-doc.cn

  1. Create a Low-Level Client API Class: If no existing Java client suits the AI model, you’ll need to develop a low-level client API class. This often involves utilizing the RestClient class from the Spring Framework, similar to the OpenAiApi class.spring-doc.cn

  2. Create a Model implementation Ensure your client conforms to the Generic Model API. Use existing request and response classes if your model’s inputs and outputs are supported. If not, create new classes for the Generic Model API and establish a new Java package.spring-doc.cn

  3. Implement Auto-Configuration and a Spring Boot Starter: This step involves creating the necessary auto-configuration and Spring Boot Starter to easily instantiate the new model with Spring Boot applications.spring-doc.cn

  4. Write Tests: All new classes should be accompanied by comprehensive tests. Existing tests can serve as a useful reference for structuring and implementing your tests.spring-doc.cn

  5. Document Your Contribution: Ensure your documentation follows the existing format, For an example of the suggested structure and formatting, refer to the Open AI Chat documentation.spring-doc.cn

By following these guidelines, we can greatly expand the framework’s range of supported models while following a common implementation and documentation pattern.spring-doc.cn