diff --git a/README.md b/README.md
index 97eaa98d2..0efbb730f 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,7 @@ And the Spring Boot Starter depending on if you are using Azure Open AI or Open
0.2.0-SNAPSHOT
```
+
## Overview
Despite the extensive history of AI, Java's role in this domain has been relatively minor.
@@ -79,7 +80,7 @@ These Python libraries share foundational themes with Spring projects, such as:
* Extensibility
* Reduction of boilerplate code
* Integration with diverse data sources
-* Prebuilt solutions for common use cases
+* Prebuilt solutions for common use cases
Taking inspiration from these libraries, the Spring AI project aims to provide a similar experience for Spring developers in the AI domain.
@@ -113,7 +114,7 @@ Instead, the 'In-context' learning technique lets you more easily incorporate yo
This data can be from text files, HTML, database results, etc.
Effectively incorporating your data in an AI model requires specific techniques critical for developing successful solutions.
-**Vector Stores:** A widely used technique to incorporate your data in a AI model is using Vector Databases.
+**Vector Stores:** A widely used technique to incorporate your data in an AI model is using Vector Databases.
Vector Databases help to classify which part of your documents are most relevant for the AI model to use in creating a response.
Examples of Vector Databases are Chroma, Pinecone, Weaviate, Mongo Atlas, and RediSearch.
Spring IO abstracts these databases, allowing easy swapping of implementations.
@@ -123,7 +124,7 @@ Spring IO abstracts these databases, allowing easy swapping of implementations.
**Chains:** Many AI solutions require multiple AI interactions to respond to a single user input.
"Chains" organize these interactions, offering modular AI workflows that promote reusability.
While you can create custom Chains tailored to your specific use case, pre-configured use-case-specific Chains are provided to accelerate your development.
-Use-cases such as Question-Answering, Text Generation, and Summarization are examples.
+Use cases such as Question-Answering, Text Generation, and Summarization are examples.
### Memory
@@ -151,7 +152,7 @@ To build including integration tests.
You will need to set environment variables for API keys to OpenAI
```shell
-./mvww clean package -Pintegration-tests
+./mvnw clean package -Pintegration-tests
```
To build the docs
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/chain/AiInput.java b/spring-ai-core/src/main/java/org/springframework/ai/chain/AiInput.java
index 0e80cad58..cffa88745 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/chain/AiInput.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/chain/AiInput.java
@@ -1,6 +1,5 @@
package org.springframework.ai.chain;
-import java.util.List;
import java.util.Map;
public class AiInput {
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/chain/AiOutput.java b/spring-ai-core/src/main/java/org/springframework/ai/chain/AiOutput.java
index 7b62ac406..3a7039df1 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/chain/AiOutput.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/chain/AiOutput.java
@@ -1,6 +1,5 @@
package org.springframework.ai.chain;
-import java.util.List;
import java.util.Map;
public class AiOutput {
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/parser/MapOutputParser.java b/spring-ai-core/src/main/java/org/springframework/ai/parser/MapOutputParser.java
index d065dcd05..2b238b8f5 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/parser/MapOutputParser.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/parser/MapOutputParser.java
@@ -1,6 +1,5 @@
package org.springframework.ai.parser;
-import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.messaging.Message;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.messaging.support.MessageBuilder;
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/parser/Parser.java b/spring-ai-core/src/main/java/org/springframework/ai/parser/Parser.java
index 6ac722e7d..2f220ccf8 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/parser/Parser.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/parser/Parser.java
@@ -1,7 +1,5 @@
package org.springframework.ai.parser;
-import java.util.Locale;
-
@FunctionalInterface
public interface Parser {
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/prompt/SystemPromptTemplate.java b/spring-ai-core/src/main/java/org/springframework/ai/prompt/SystemPromptTemplate.java
index aba74047a..73d84902c 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/prompt/SystemPromptTemplate.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/prompt/SystemPromptTemplate.java
@@ -16,13 +16,12 @@
package org.springframework.ai.prompt;
-import java.util.List;
-import java.util.Map;
-
import org.springframework.ai.prompt.messages.Message;
import org.springframework.ai.prompt.messages.SystemMessage;
import org.springframework.core.io.Resource;
+import java.util.Map;
+
public class SystemPromptTemplate extends PromptTemplate {
public SystemPromptTemplate(String template) {
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/SystemMessage.java b/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/SystemMessage.java
index 451c540df..311790451 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/SystemMessage.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/SystemMessage.java
@@ -18,8 +18,6 @@ package org.springframework.ai.prompt.messages;
import org.springframework.core.io.Resource;
-import java.util.Map;
-
/**
* A message of the type 'system' passed as input. The system message gives high level
* instructions for the conversation. This role typically provides high-level instructions
diff --git a/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/UserMessage.java b/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/UserMessage.java
index 64767e681..8c7fdcae6 100644
--- a/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/UserMessage.java
+++ b/spring-ai-core/src/main/java/org/springframework/ai/prompt/messages/UserMessage.java
@@ -18,8 +18,6 @@ package org.springframework.ai.prompt.messages;
import org.springframework.core.io.Resource;
-import java.util.Map;
-
/**
* A message of the type 'user' passed as input Messages with the user role are from the
* end-user or developer. They represent questions, prompts, or any input that you want
diff --git a/spring-ai-docs/concepts-staging.adoc b/spring-ai-docs/concepts-staging.adoc
index b0ed2e708..26873e2d3 100644
--- a/spring-ai-docs/concepts-staging.adoc
+++ b/spring-ai-docs/concepts-staging.adoc
@@ -3,7 +3,7 @@
Prompts serve as the foundation for language-based inputs that guide an AI model to produce specific outputs.
While this might seem intuitive considering our interactions with ChatGPT, crafting effective prompts involves both an art and a science.
-The wording of the language utilized significantly impacts the AI model's responses, and there specific patters and words are recognized by the model to guide responses in the intended direction.
+The wording of the language utilized significantly impacts the AI model's responses, and their specific patterns and words are recognized by the model to guide responses in the intended direction.
The importance of this skill has led to the emergence of "Prompt Engineering."
When an effective prompt for a particular use case is identified, it is often shared within the community.
@@ -18,7 +18,7 @@ Spring AI employs the OSS library, StringTemplate, for this purpose.
For instance, consider the simple prompt template: Tell me a {adjective} joke about {content}.
In Spring AI, Prompt Templates can be likened to the 'View' in Spring MVC architecture.
-A model object, typically a java.util.Map, is provided to populate placeholders within the template.
+A model object, typically a `java.util.Map`, is provided to populate placeholders within the template.
The 'rendered' string becomes the content of the Prompt supplied to the AI model.
There is considerable variability in the specific data format of the Prompt sent to the model.
@@ -58,17 +58,17 @@ This challenge has prompted OpenAI to introduce 'OpenAI Functions' as a means to
== Chaining Calls
-A Chain is the concept that represents a series of calls to a AI model.
+A Chain is a concept that represents a series of calls to an AI model.
It uses the output from one call as the input to another.
-By chaining calls together, you can support complex use-cases by composing pipelines of multiple chains.
+By chaining calls together, you can support complex use cases by composing pipelines of multiple chains.
== Customizing Models: Integrating Your Data
How can you equip the AI model with information it hasn't been trained on?
It's important to note that the GPT 3.5/4.0 dataset extends only until September 2021.
-Consequently, the model will say that it doesn't know the answer for questions that require knowledge beyond that date.
+Consequently, the model will say that it doesn't know the answer to questions that require knowledge beyond that date.
An interesting bit of trivia is that this dataset is around ~650GB.
Two techniques exist for customizing the AI model to incorporate your data:
diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/concepts.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/concepts.adoc
index 9e0e330ea..1bd88aeaf 100644
--- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/concepts.adoc
+++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/concepts.adoc
@@ -3,7 +3,7 @@
== Models
AI models are algorithms designed to process and generate information, often mimicking human cognitive functions.
-By learning patterns and insights from large datasets, these models can make predictions, generate text, images, or other outputs, enhancing various applications across industries.
+By learning patterns and insights from large datasets, these models can make predictions, text, images, or other outputs, enhancing various applications across industries.
There are many different types of AI models, each suited for a specific use case.
While ChatGPT and its generative AI capabilities have captivated users through text input and output, many models and companies offer diverse inputs and outputs.
@@ -18,7 +18,7 @@ The following table categorizes several models based on their input and output t
|Output
|Examples
-|Language/Code/Images (Multi Modal)
+|Language/Code/Images (Multi-Modal)
|Language/Code
|GPT4 - OpenAI
@@ -41,7 +41,7 @@ The following table categorizes several models based on their input and output t
The initial focus of Spring AI is on models that process language input and provide language output, initially OpenAI + Azure OpenAI.
The last row in the previous table, which accepts text as input and output numbers, is more commonly known as Embedding text and represents the internal data structures used in an AI model.
-Spring AI has support for Embeddings to support more advanced use-cases.
+Spring AI has support for Embeddings to support more advanced use cases.
What sets models like GPT apart is their pre-trained nature, as indicated by the "P" in GPT—Chat Generative Pre-Trained Transformer.
This pre-training feature transforms AI into a general developer tool that doesn't necessitate an extensive machine learning or model training background.
@@ -51,7 +51,7 @@ This pre-training feature transforms AI into a general developer tool that doesn
Prompts serve as the foundation for language-based inputs that guide an AI model to produce specific outputs.
While this might seem intuitive considering our interactions with ChatGPT, crafting effective prompts involves both an art and a science.
-The wording of the language utilized significantly impacts the AI model's responses, and there specific patters and words are recognized by the model to guide responses in the intended direction.
+The wording of the language utilized significantly impacts the AI model's responses, and their specific patterns and words are recognized by the model to guide responses in the intended direction.
The importance of this skill has led to the emergence of "Prompt Engineering."
When an effective prompt for a particular use case is identified, it is often shared within the community.
@@ -71,7 +71,7 @@ Tell me a {adjective} joke about {content}.
```
In Spring AI, Prompt Templates can be likened to the 'View' in Spring MVC architecture.
-A model object, typically a java.util.Map, is provided to populate placeholders within the template.
+A model object, typically a `java.util.Map`, is provided to populate placeholders within the template.
The 'rendered' string becomes the content of the Prompt supplied to the AI model.
There is considerable variability in the specific data format of the Prompt sent to the model.
@@ -112,17 +112,17 @@ This challenge has prompted OpenAI to introduce 'OpenAI Functions' as a means to
== Chaining Calls
-A Chain is the concept that represents a series of calls to a AI model.
+A Chain is a concept that represents a series of calls to an AI model.
It uses the output from one call as the input to another.
-By chaining calls together, you can support complex use-cases by composing pipelines of multiple chains.
+By chaining calls together, you can support complex use cases by composing pipelines of multiple chains.
== Customizing Models: Integrating Your Data
How can you equip the AI model with information it hasn't been trained on?
It's important to note that the GPT 3.5/4.0 dataset extends only until September 2021.
-Consequently, the model will say that it doesn't know the answer for questions that require knowledge beyond that date.
+Consequently, the model will say that it doesn't know the answer to questions that require knowledge beyond that date.
An interesting bit of trivia is that this dataset is around ~650GB.
Two techniques exist for customizing the AI model to incorporate your data:
@@ -162,8 +162,8 @@ TBD
== Evaluating AI responses
-Effectively evaluating the output of an AI system in response to user requests is very important to ensuring accuracy and usefulness of the final application.
-Several emerging techniques enable the use of the pretrained model itself for this purpose.
+Effectively evaluating the output of an AI system in response to user requests is very important to ensuring the accuracy and usefulness of the final application.
+Several emerging techniques enable the use of the pre-trained model itself for this purpose.
This evaluation process involves analyzing whether the generated response aligns with the user's intent and the context of the query. Metrics such as relevance, coherence, and factual correctness are used to gauge the quality of the AI-generated response.
diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/index.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/index.adoc
index f7693b5e5..d650646ed 100644
--- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/index.adoc
+++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/index.adoc
@@ -12,12 +12,12 @@ These abstractions have multiple implementations, enabling easy component swappi
For example, Spring AI introduces the AiClient interface with implementations for OpenAI and Azure OpenAI.
In addition to these core abstractions, Spring AI aims to provide higher-level functionalities to address common use cases such as "Q&A over your documentation" or "Chat with your documentation."
-As the complexity of the use cases increase, the Spring AI project will integration with other projects in the Spring Ecosystem such as Spring Integration, Spring Batch, and Spring Data.
+As the complexity of the use cases increases, the Spring AI project will integrate with other projects in the Spring Ecosystem such as Spring Integration, Spring Batch, and Spring Data.
To simplify setup, Spring Boot Starters are available to help set up essential dependencies and classes.
There is also a collection of sample applications to help you explore the project's features.
Lastly, the new Spring CLI project also enables you to get started quickly using the command `spring boot new ai` for new projects or `spring boot add ai` for adding AI capabilities to your existing application.
-The next section, provides a high level overview of AI concepts and their representation in Spring AI.
+The next section provides a high-level overview of AI concepts and their representation in Spring AI.
The Getting Started section shows you how to create your first AI application
Subsequent sections delve into each component and common use cases with a code-focused approach.
diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java
index b0854e7e4..c9c8fb605 100644
--- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java
+++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java
@@ -19,10 +19,8 @@ package org.springframework.ai.autoconfigure.azure.openai;
import com.azure.ai.openai.OpenAIClient;
import com.azure.ai.openai.OpenAIClientBuilder;
import com.azure.core.credential.AzureKeyCredential;
-
import org.springframework.ai.azure.openai.client.AzureOpenAiClient;
import org.springframework.ai.azure.openai.embedding.AzureOpenAiEmbeddingClient;
-import org.springframework.ai.openai.embedding.OpenAiEmbeddingClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiProperties.java
index 8fd329b91..a31b5e00d 100644
--- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiProperties.java
+++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiProperties.java
@@ -16,8 +16,6 @@
package org.springframework.ai.autoconfigure.azure.openai;
-import java.net.URI;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(AzureOpenAiProperties.CONFIG_PREFIX)