|
1 | 1 | # Spring AI [](https://github.com/spring-projects/spring-ai/actions/workflows/continuous-integration.yml)
|
2 | 2 |
|
3 |
| -Welcome to the Spring AI project! |
4 |
| - |
5 | 3 | The Spring AI project provides a Spring-friendly API and abstractions for developing AI applications.
|
6 | 4 |
|
7 |
| -Let's make your `@Beans` intelligent! |
8 |
| - |
9 |
| -For further information go to our [Spring AI reference documentation](https://docs.spring.io/spring-ai/reference/). |
10 |
| - |
11 |
| -## Breaking changes |
12 |
| - |
13 |
| -* Refer to the [upgrade notes](https://docs.spring.io/spring-ai/reference/upgrade-notes.html) to see how to upgrade to 1.0.0.M1 or higher. |
14 |
| - |
15 |
| -## Project Links |
16 |
| - |
17 |
| -* [Documentation](https://docs.spring.io/spring-ai/reference/) |
18 |
| -* [Issues](https://github.com/spring-projects/spring-ai/issues) |
19 |
| -* [Discussions](https://github.com/spring-projects/spring-ai/discussions) - Go here if you have a question, suggestion, or feedback! |
20 |
| - |
21 |
| - |
22 |
| -## Educational Resources |
23 |
| - |
24 |
| -- Follow the [Workshop material for Azure OpenAI](https://github.com/Azure-Samples/spring-ai-azure-workshop) |
25 |
| - - The workshop contains step-by-step examples from 'hello world' to 'retrieval augmented generation' |
26 |
| - |
27 |
| -Some selected videos. Search YouTube! for more. |
28 |
| - |
29 |
| -- Spring Tips: Spring AI |
30 |
| -<br>[](https://www.youtube.com/watch?v=aNKDoiOUo9M) |
31 |
| -* Overview of Spring AI @ Devoxx 2023 |
32 |
| -<br>[](https://www.youtube.com/watch?v=7OY9fKVxAFQ) |
33 |
| -* Introducing Spring AI - Add Generative AI to your Spring Applications |
34 |
| -<br>[](https://www.youtube.com/watch?v=1g_wuincUdU) |
35 |
| - |
36 |
| -## Getting Started |
37 |
| - |
38 |
| -Please refer to the [Getting Started Guide](https://docs.spring.io/spring-ai/reference/getting-started.html) for instruction on adding your dependencies. |
39 |
| - |
40 |
| -Note, the new Spring CLI project lets you get up and running in two simple steps, [described in detail here](https://docs.spring.io/spring-ai/reference/getting-started.html#spring-cli). |
41 |
| -1. Install Spring CLI |
42 |
| -2. Type `spring boot new --from ai --name myai` in your terminal |
43 |
| - |
44 |
| - |
45 |
| -### Adding Dependencies manually |
46 |
| - |
47 |
| -Note that are two main steps. |
48 |
| - |
49 |
| -1. [Add the Spring Milestone and Snapshot repositories to your build system](https://docs.spring.io/spring-ai/reference/getting-started.html#repositories). |
50 |
| -2. Add the [Spring AI BOM](https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management) |
51 |
| -3. [Add dependencies](https://docs.spring.io/spring-ai/reference/getting-started.html#add-dependencies) for the specific AI model, Vector Database or other component dependencies you require. |
52 |
| - |
53 |
| - |
54 |
| -## Overview |
55 |
| - |
56 |
| -Despite the extensive history of AI, Java's role in this domain has been relatively minor. |
57 |
| -This is mainly due to the historical reliance on efficient algorithms developed in languages such as C/C++, with Python serving as a bridge to access these libraries. |
58 |
| -The majority of ML/AI tools were built around the Python ecosystem. |
59 |
| -However, recent progress in Generative AI, spurred by innovations like OpenAI's ChatGPT, has popularized the interaction with pre-trained models via HTTP. |
60 |
| -This eliminates much of the dependency on C/C++/Python libraries and opens the door to the use of programming languages such as Java. |
| 5 | +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. |
61 | 6 |
|
| 7 | + |
62 | 8 |
|
63 |
| -The Python libraries [LangChain](https://docs.langchain.com/docs/) and [LlamaIndex](https://gpt-index.readthedocs.io/en/latest/getting_started/concepts.html) have become popular to implement Generative AI solutions and can be implemented in other programming languages. |
64 |
| -These Python libraries share foundational themes with Spring projects, such as: |
| 9 | +> At its core, Spring AI addresses the fundamental challenge of AI integration: Connecting your enterprise __Data__ and __APIs__ with the __AI Models__. |
65 | 10 |
|
66 |
| -* Portable Service Abstractions |
67 |
| -* Modularity |
68 |
| -* Extensibility |
69 |
| -* Reduction of boilerplate code |
70 |
| -* Integration with diverse data sources |
71 |
| -* Prebuilt solutions for common use cases |
| 11 | +For further information go to our [Spring AI Reference Documentation](https://docs.spring.io/spring-ai/reference/). |
72 | 12 |
|
73 |
| -Taking inspiration from these libraries, the Spring AI project aims to provide a similar experience for Spring developers in the AI domain. |
74 |
| - |
75 |
| -Note, that the Spring AI API is not a direct port of either LangChain or LlamaIndex. You will see significant differences in the API if you are familiar with those two projects, though concepts and ideas are fairly portable. |
76 |
| - |
77 |
| -## Feature Overview |
| 13 | +The project draws inspiration from notable Python projects, such as [LangChain](https://docs.langchain.com/docs/) and [LlamaIndex](https://gpt-index.readthedocs.io/en/latest/getting_started/concepts.html), 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. |
78 | 14 |
|
79 | 15 | This is a high level feature overview.
|
80 |
| -The features that are implemented lay the foundation, with subsequent more complex features building upon them. |
81 |
| - |
82 | 16 | You can find more details in the [Reference Documentation](https://docs.spring.io/spring-ai/reference/)
|
83 | 17 |
|
84 |
| -### Interacting with AI Models |
85 |
| - |
86 |
| -**ChatClient:** A foundational feature of Spring AI is a portable client API for interacting with generative AI models. With this portable API, you can initially target one AI chat model, for example OpenAI and then easily swap out the implementation to another AI chat model, for example Amazon Bedrock's Anthropic Model. When necessary, you can also drop down to use non-portable model options. |
87 |
| - |
88 |
| -Spring AI supports many AI models. For an overview see here. Specific models currently supported are |
89 |
| -* OpenAI |
90 |
| -* Azure OpenAI |
91 |
| -* Amazon Bedrock (Anthropic, Llama, Cohere, Titan, Jurassic2) |
92 |
| -* Hugging Face |
93 |
| -* Google VertexAI (PaLM2, Gemini) |
94 |
| -* Mistral AI |
95 |
| -* Stability AI |
96 |
| -* Ollama |
97 |
| -* PostgresML |
98 |
| -* Transformers (ONNX) |
99 |
| -* Anthropic Claude3 |
100 |
| -* MiniMax |
101 |
| -* Moonshot |
102 |
| - |
103 |
| - |
104 |
| -**Prompts:** Central to AI model interaction is the Prompt, which provides specific instructions for the AI to act upon. |
105 |
| -Crafting an effective Prompt is both an art and science, giving rise to the discipline of "Prompt Engineering". |
106 |
| -These prompts often leverage a templating engine for easy data substitution within predefined text using placeholders. |
107 |
| - |
108 |
| -Explore more on [Prompts](https://docs.spring.io/spring-ai/reference/concepts.html#_prompts) in our concept guide. |
109 |
| -To learn about the Prompt class, refer to the [Prompt API guide](https://docs.spring.io/spring-ai/reference/api/prompt.html). |
110 |
| - |
111 |
| -**Prompt Templates:** Prompt Templates support the creation of prompts, particularly when a Template Engine is employed. |
112 |
| - |
113 |
| -Delve into PromptTemplates in our [concept guide](https://docs.spring.io/spring-ai/reference/concepts.html#_prompt_templates). |
114 |
| -For a hands-on guide to PromptTemplate, see the [PromptTemplate API guide](https://docs.spring.io/spring-ai/reference/api/prompt-template.html). |
115 |
| - |
116 |
| -**Output Parsers:** AI model outputs often come as raw `java.lang.String` values. Output Parsers restructure these raw strings into more programmer-friendly formats, such as CSV or JSON. |
117 |
| - |
118 |
| -Get insights on Output Parsers in our [concept guide](https://docs.spring.io/spring-ai/reference/concepts.html#_output_parsing).. |
119 |
| -For implementation details, visit the [StructuredOutputConverter API guide](https://docs.spring.io/spring-ai/reference/api/output-parser.html). |
| 18 | +* Support for all major [AI Model providers](https://docs.spring.io/spring-ai/reference/api/index.html) such as Anthropic, OpenAI, Microsoft, Amazon, Google, and Ollama. Supported model types include: |
| 19 | + - [Chat Completion](https://docs.spring.io/spring-ai/reference/api/chatmodel.html) |
| 20 | + - [Embedding](https://docs.spring.io/spring-ai/reference/api/embeddings.html) |
| 21 | + - [Text to Image](https://docs.spring.io/spring-ai/reference/api/imageclient.html) |
| 22 | + - [Audio Transcription](https://docs.spring.io/spring-ai/reference/api/audio/transcriptions.html) |
| 23 | + - [Text to Speech](https://docs.spring.io/spring-ai/reference/api/audio/speech.html) |
| 24 | + - [Moderation](https://docs.spring.io/spring-ai/reference/api/index.html#api/moderation) |
| 25 | +* Portable API support across AI providers for both synchronous and streaming API options are supported. Access to [model-specific features](https://docs.spring.io/spring-ai/reference/api/chatmodel.html#_chat_options) is also available. |
| 26 | +* [Structured Outputs](https://docs.spring.io/spring-ai/reference/api/structured-output-converter.html) - Mapping of AI Model output to POJOs. |
| 27 | +* Support for all major [Vector Database providers](https://docs.spring.io/spring-ai/reference/api/vectordbs.html) such as *Apache Cassandra, Azure Vector Search, Chroma, Milvus, MongoDB Atlas, Neo4j, Oracle, PostgreSQL/PGVector, PineCone, Qdrant, Redis, and Weaviate*. |
| 28 | +* Portable API across Vector Store providers, including a novel SQL-like [metadata filter API](https://docs.spring.io/spring-ai/reference/api/vectordbs.html#metadata-filters). |
| 29 | +* [Tools/Function Calling](https://docs.spring.io/spring-ai/reference/api/functions.html) - permits the model to request the execution of client-side tools and functions, thereby accessing necessary real-time information as required. |
| 30 | +* [Observability](https://docs.spring.io/spring-ai/reference/observability/index.html) - Provides insights into AI-related operations. |
| 31 | +* Document injection [ETL framework](https://docs.spring.io/spring-ai/reference/api/etl-pipeline.html) for Data Engineering. |
| 32 | +* [AI Model Evaluation](https://docs.spring.io/spring-ai/reference/api/testing.html) - Utilities to help evaluate generated content and protect against hallucinated response. |
| 33 | +* [ChatClient API](https://docs.spring.io/spring-ai/reference/api/chatclient.html) - Fluent API for communicating with AI Chat Models, idiomatically similar to the WebClient and RestClient APIs. |
| 34 | +* [Advisors API](https://docs.spring.io/spring-ai/reference/api/advisors.html) - Encapsulates recurring Generative AI patterns, transforms data sent to and from Language Models (LLMs), and provides portability across various models and use cases. |
| 35 | +* Support for [Chat Conversation Memory](https://docs.spring.io/spring-ai/reference/api/chatclient.html#_chat_memory) and [Retrieval Augmented Generation (RAG)](https://docs.spring.io/spring-ai/reference/api/chatclient.html#_retrieval_augmented_generation). |
| 36 | +* Spring Boot Auto Configuration and Starters for all AI Models and Vector Stores - use the [start.spring.io](https://start.spring.io/) to select the Model or Vector-store of choice. |
120 | 37 |
|
121 |
| -### Incorporating your data |
122 |
| - |
123 |
| -Incorporating proprietary data into Generative AI without retraining the model has been a breakthrough. |
124 |
| -Retraining models, especially those with billions of parameters, is challenging due to the specialized hardware required. |
125 |
| -The 'In-context' learning technique provides a simpler method to infuse your pre-trained model with data, whether from text files, HTML, or database results. |
126 |
| -The right techniques are critical for developing successful solutions. |
127 |
| - |
128 |
| - |
129 |
| -#### Retrieval Augmented Generation |
130 |
| - |
131 |
| -Retrieval Augmented Generation, or RAG for short, is a pattern that enables you to bring your data to pre-trained models. |
132 |
| -RAG excels in the 'query over your docs' use-case. |
133 |
| - |
134 |
| -Learn more about [Retrieval Augmented Generation](https://docs.spring.io/spring-ai/reference/concepts.html#_retrieval_augmented_generation). |
135 |
| - |
136 |
| -Bringing your data to the model follows an Extract, Transform, and Load (ETL) pattern. |
137 |
| -The subsequent classes and interfaces support RAG's data preparation. |
138 |
| - |
139 |
| -**Documents:** |
140 |
| - |
141 |
| -The `Document` class encapsulates your data, including text and metadata, for the AI model. |
142 |
| -While a Document can represent extensive content, such as an entire file, the RAG approach |
143 |
| -segments content into smaller pieces for inclusion in the prompt. |
144 |
| -The ETL process uses the interfaces `DocumentReader`, `DocumentTransformer`, and `DocumentWriter`, ending with data storage in a Vector Database. |
145 |
| -This database later discerns the pieces of data that are pertinent to a user's query. |
146 |
| - |
147 |
| - |
148 |
| -**Document Readers:** |
149 |
| - |
150 |
| -Document Readers produce a `List<Document>` from diverse sources like PDFs, Markdown files, and Word documents. |
151 |
| -Given that many sources are unstructured, Document Readers often segment based on content semantics, avoiding splits within tables or code sections. |
152 |
| -After the initial creation of the `List<Document>`, the data flows through transformers for further refinement. |
153 |
| - |
154 |
| -**Document Transformers:** |
155 |
| - |
156 |
| -Transformers further modify the `List<Document>` by eliminating superfluous data, like PDF margins, or appending metadata (e.g., primary keywords or summaries). |
157 |
| -Another critical transformation is subdividing documents to fit within the AI model's token constraints. |
158 |
| -Each model has a context-window indicating its input and output data limits. Typically, one token equates to about 0.75 words. For instance, in model names like gpt-4-32k, "32K" signifies the token count. |
159 |
| - |
160 |
| -**Document Writers:** |
| 38 | +## Breaking changes |
161 | 39 |
|
162 |
| -The final ETL step within RAG involves committing the data segments to a Vector Database. |
163 |
| -Though the `DocumentWriter` interface isn't exclusively for Vector Database writing, it the main type of implementation. |
| 40 | +* Refer to the [upgrade notes](https://docs.spring.io/spring-ai/reference/upgrade-notes.html) to see how to upgrade to 1.0.0.M1 or higher. |
164 | 41 |
|
165 |
| -**Vector Stores:** Vector Databases are instrumental in incorporating your data with AI models. |
166 |
| -They ascertain which document sections the AI should use for generating responses. |
167 |
| -Examples of Vector Databases include Chroma, Oracle, Postgres, Pinecone, Qdrant, Weaviate, Mongo Atlas, and Redis. Spring AI's `VectorStore` abstraction permits effortless transitions between database implementations. |
| 42 | +## Getting Started |
168 | 43 |
|
| 44 | +Please refer to the [Getting Started Guide](https://docs.spring.io/spring-ai/reference/getting-started.html) for instruction on adding your dependencies. |
169 | 45 |
|
170 | 46 |
|
171 | 47 | ## Cloning the repo
|
@@ -218,3 +94,64 @@ To check javadocs using the [javadoc:javadoc](https://maven.apache.org/plugins/m
|
218 | 94 | ```shell
|
219 | 95 | ./mvnw javadoc:javadoc -Pjavadoc
|
220 | 96 | ```
|
| 97 | + |
| 98 | +## Project Links |
| 99 | + |
| 100 | +* [Documentation](https://docs.spring.io/spring-ai/reference/) |
| 101 | +* [Issues](https://github.com/spring-projects/spring-ai/issues) |
| 102 | +<!-- * [Discussions](https://github.com/spring-projects/spring-ai/discussions) - Go here if you have a question, suggestion, or feedback! --> |
| 103 | + |
| 104 | + |
| 105 | +## Educational Resources |
| 106 | + |
| 107 | + |
| 108 | +### Spring AI blogs: |
| 109 | +- [Leverage the Power of 45k, free, Hugging Face Models with Spring AI and Ollama](https://spring.io/blog/2024/10/22/leverage-the-power-of-45k-free-hugging-face-models-with-spring-ai-and-ollama) |
| 110 | +- [Supercharging Your AI Applications with Spring AI Advisors](https://spring.io/blog/2024/10/02/supercharging-your-ai-applications-with-spring-ai-advisors) |
| 111 | +- [Spring AI with NVIDIA LLM API](https://spring.io/blog/2024/08/20/spring-ai-with-nvidia-llm-api) |
| 112 | +- [Spring AI Embraces OpenAI's Structured Outputs: Enhancing JSON Response Reliability](https://spring.io/blog/2024/08/09/spring-ai-embraces-openais-structured-outputs-enhancing-json-response) |
| 113 | +- [Spring AI with Groq - a blazingly fast AI inference engine](https://spring.io/blog/2024/07/31/spring-ai-with-groq-a-blazingly-fast-ai-inference-engine) |
| 114 | +- [Spring AI with Ollama Tool Support](https://spring.io/blog/2024/07/26/spring-ai-with-ollama-tool-support) |
| 115 | +- [Spring AI - Structured Output](https://spring.io/blog/2024/05/09/spring-ai-structured-output) |
| 116 | +- [Spring AI - Multimodality - Orbis Sensualium Pictus](https://spring.io/blog/2024/04/19/spring-ai-multimodality-orbis-sensualium-pictus) |
| 117 | +- [Function Calling in Java and Spring AI using the latest Mistral AI API](https://spring.io/blog/2024/03/06/function-calling-in-java-and-spring-ai-using-the-latest-mistral-ai-api) |
| 118 | +- [AI Meets Spring Petclinic: Implementing an AI Assistant with Spring AI (Part I)](https://spring.io/blog/2024/09/26/ai-meets-spring-petclinic-implementing-an-ai-assistant-with-spring-ai-part-i) |
| 119 | +- [AI Meets Spring Petclinic: Implementing an AI Assistant with Spring AI (Part II)](https://spring.io/blog/2024/09/27/ai-meets-spring-petclinic-implementing-an-ai-assistant-with-spring-ai-part) |
| 120 | + |
| 121 | +### Code Examples |
| 122 | + |
| 123 | +- [Flight Booking Assistant](https://github.com/tzolov/playground-flight-booking) - Spring AI powered expert system demo |
| 124 | +- [Spring AI Chat Bot CLI](https://github.com/tzolov/spring-ai-cli-chatbot) - chatbot with Retrieval-Augmented Generation (RAG) and conversational memory capabilities |
| 125 | +- [Spring AI Samples (community driven) Thomas Vitale](https://github.com/ThomasVitale/llm-apps-java-spring-ai) - Samples showing how to build Java applications powered by Generative AI and Large Language Models (LLMs) |
| 126 | +- [spring-ai-examples - (community driven) Craig Walls ](https://github.com/habuma/spring-ai-examples) |
| 127 | + |
| 128 | +### Workshops |
| 129 | + |
| 130 | +- [Spring AI Zero to Hero Workshop](https://github.com/asaikali/spring-ai-zero-to-hero) - Example applications showing how to use Spring AI to build Generative AI projects. |
| 131 | +- (outdated) [Workshop material for Azure OpenAI](https://github.com/Azure-Samples/spring-ai-azure-workshop) - contains step-by-step examples from 'hello world' to 'retrieval augmented generation' |
| 132 | + |
| 133 | +### Talks and Videos |
| 134 | + |
| 135 | +Some selected videos. Search YouTube! for more. |
| 136 | + |
| 137 | +- Spring AI: Seamlessly Integrating AI into Your Enterprise Java Applications (2024 - Devoxx.be) |
| 138 | +<br>[](https://youtu.be/kfRyY0wsZHM?si=qzIshk0GJqVTyrNm) |
| 139 | + |
| 140 | +- Spring AI Is All You Need (2024 - GOTO Amsterdam) |
| 141 | +<br>[](https://youtu.be/vuhMti8B5H0?si=qhRVLh4-EaUhm9oe) |
| 142 | + |
| 143 | +- Introducing Spring AI (2024 - Spring.IO) |
| 144 | +<br>[](https://youtu.be/umKbaXsiCOY?si=FbqCtLIOgbihm6b6) |
| 145 | + |
| 146 | +- Spring AI at Spring.IO Keynotes (2024 - Spring.IO) |
| 147 | +<br>[](https://youtu.be/XUz4LKZx83g?t=2940) |
| 148 | + |
| 149 | +- Spring Tips: Spring AI |
| 150 | +<br>[](https://www.youtube.com/watch?v=aNKDoiOUo9M) |
| 151 | +* Overview of Spring AI @ Devoxx 2023 |
| 152 | +<br>[](https://www.youtube.com/watch?v=7OY9fKVxAFQ) |
| 153 | +* Introducing Spring AI - Add Generative AI to your Spring Applications |
| 154 | +<br>[](https://www.youtube.com/watch?v=1g_wuincUdU) |
| 155 | + |
| 156 | +- Spring AI Introduction: Building AI Applications in Java with Spring |
| 157 | +<br>[](https://www.youtube.com/watch?v=yyvjT0v3lpY&ab_channel=DanVega) |
0 commit comments