Skip to content

Commit 97e4628

Browse files
author
lobo
committed
merge main into add-huggingface-text-to-image
1 parent 89ffb0c commit 97e4628

File tree

933 files changed

+28057
-8886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

933 files changed

+28057
-8886
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
distribution: 'temurin'
2626
cache: 'maven'
2727

28+
- name: Configure Testcontainers
29+
run: |
30+
echo "testcontainers.reuse.enable=true" > $HOME/.testcontainers.properties
31+
2832
# - name: Cache Docker images.
2933
# uses: ScribeMD/[email protected]
3034
# with:
@@ -36,7 +40,10 @@ jobs:
3640
SPRING_AI_OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3741
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
3842
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
39-
run: mvn -s settings.xml -Pintegration-tests -Pjavadoc -Dfailsafe.rerunFailingTestsCount=3 --batch-mode --update-snapshots deploy
43+
OLLAMA_AUTOCONF_TESTS_ENABLED: "true"
44+
run: |
45+
mvn -s settings.xml -Pintegration-tests -Pjavadoc -Dfailsafe.rerunFailingTestsCount=3 \
46+
--batch-mode --update-snapshots deploy
4047
4148
- name: Generate Java docs
4249
run: mvn javadoc:aggregate
@@ -66,5 +73,40 @@ jobs:
6673
working-directory: spring-ai-docs/target
6774
run: |
6875
unzip spring-ai-$PROJECT_VERSION-docs.zip
69-
ssh -i $HOME/.ssh/key $DOCS_USERNAME@$DOCS_HOST "cd $DOCS_PATH && mkdir -p $PROJECT_VERSION/api"
70-
scp -i $HOME/.ssh/key -r api $DOCS_USERNAME@$DOCS_HOST:$DOCS_PATH/$PROJECT_VERSION/api
76+
ssh -i $HOME/.ssh/key $DOCS_USERNAME@$DOCS_HOST "cd $DOCS_PATH && mkdir -p $PROJECT_VERSION"
77+
scp -i $HOME/.ssh/key -r api $DOCS_USERNAME@$DOCS_HOST:$DOCS_PATH/$PROJECT_VERSION
78+
79+
80+
# The docker-compose and testcontainers modules will be compiled and run in a parallel job
81+
container-tests:
82+
name: docker-compose and testcontainers modules
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Checkout source code
86+
uses: actions/checkout@v4
87+
88+
- name: Set up JDK 17
89+
uses: actions/setup-java@v4
90+
with:
91+
java-version: '17'
92+
distribution: 'temurin'
93+
cache: 'maven'
94+
95+
- name: Configure Testcontainers
96+
run: |
97+
echo "testcontainers.reuse.enable=true" > $HOME/.testcontainers.properties
98+
99+
- name: Build Dependencies
100+
run: |
101+
mvn -s settings.xml clean install \
102+
-DskipTests \
103+
-pl spring-ai-spring-boot-docker-compose,spring-ai-spring-boot-testcontainers \
104+
-am --batch-mode
105+
106+
- name: Run docker-compost and testcontainers Integration Tests
107+
run: |
108+
mvn -s settings.xml -Pintegration-tests verify \
109+
-Dskip.docker-compose=false \
110+
-Dskip.testcontainers=false \
111+
-pl spring-ai-spring-boot-docker-compose,spring-ai-spring-boot-testcontainers \
112+
--batch-mode

.github/workflows/documentation-upload.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
cache: 'maven'
2727

2828
- name: Generate Java docs
29+
run: mvn clean install -DskipTests -Pjavadoc
30+
31+
- name: Aggregate Java docs
2932
run: mvn javadoc:aggregate
3033

3134
- name: Generate assembly
@@ -50,6 +53,6 @@ jobs:
5053
working-directory: spring-ai-docs/target
5154
run: |
5255
unzip spring-ai-$RELEASE_VERSION-docs.zip
53-
ssh -i $HOME/.ssh/key $DOCS_USERNAME@$DOCS_HOST "cd $DOCS_PATH && mkdir -p $RELEASE_VERSION/api"
56+
ssh -i $HOME/.ssh/key $DOCS_USERNAME@$DOCS_HOST "cd $DOCS_PATH && mkdir -p $RELEASE_VERSION"
5457
scp -i $HOME/.ssh/key -r api $DOCS_USERNAME@$DOCS_HOST:$DOCS_PATH/$RELEASE_VERSION
5558

README.md

Lines changed: 16 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,21 @@ You can find more details in the [Reference Documentation](https://docs.spring.i
3535
* 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).
3636
* 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.
3737

38-
## Breaking changes
39-
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.
41-
4238
## Getting Started
4339

4440
Please refer to the [Getting Started Guide](https://docs.spring.io/spring-ai/reference/getting-started.html) for instruction on adding your dependencies.
4541

42+
## Project Resources
43+
44+
* [Documentation](https://docs.spring.io/spring-ai/reference/)
45+
* [Issues](https://github.com/spring-projects/spring-ai/issues)
46+
<!-- * [Discussions](https://github.com/spring-projects/spring-ai/discussions) - Go here if you have a question, suggestion, or feedback! -->
47+
* [Awesome Spring AI](https://github.com/danvega/awesome-spring-ai) - A curated list of awesome resources, tools, tutorials, and projects for building generative AI applications using Spring AI
48+
49+
## Breaking changes
50+
51+
* 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.
52+
4653
## Cloning the repo
4754

4855
This repository contains [large model files](https://github.com/spring-projects/spring-ai/tree/main/models/spring-ai-transformers/src/main/resources/onnx/all-MiniLM-L6-v2).
@@ -94,63 +101,11 @@ To check javadocs using the [javadoc:javadoc](https://maven.apache.org/plugins/m
94101
./mvnw javadoc:javadoc -Pjavadoc
95102
```
96103

97-
## Project Links
98-
99-
* [Documentation](https://docs.spring.io/spring-ai/reference/)
100-
* [Issues](https://github.com/spring-projects/spring-ai/issues)
101-
<!-- * [Discussions](https://github.com/spring-projects/spring-ai/discussions) - Go here if you have a question, suggestion, or feedback! -->
102-
103-
104-
## Educational Resources
105-
106-
107-
### Spring AI blogs:
108-
- [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)
109-
- [Supercharging Your AI Applications with Spring AI Advisors](https://spring.io/blog/2024/10/02/supercharging-your-ai-applications-with-spring-ai-advisors)
110-
- [Spring AI with NVIDIA LLM API](https://spring.io/blog/2024/08/20/spring-ai-with-nvidia-llm-api)
111-
- [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)
112-
- [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)
113-
- [Spring AI with Ollama Tool Support](https://spring.io/blog/2024/07/26/spring-ai-with-ollama-tool-support)
114-
- [Spring AI - Structured Output](https://spring.io/blog/2024/05/09/spring-ai-structured-output)
115-
- [Spring AI - Multimodality - Orbis Sensualium Pictus](https://spring.io/blog/2024/04/19/spring-ai-multimodality-orbis-sensualium-pictus)
116-
- [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)
117-
- [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)
118-
- [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)
119-
120-
### Code Examples
121-
122-
- [Flight Booking Assistant](https://github.com/tzolov/playground-flight-booking) - Spring AI powered expert system demo
123-
- [Spring AI Chat Bot CLI](https://github.com/tzolov/spring-ai-cli-chatbot) - chatbot with Retrieval-Augmented Generation (RAG) and conversational memory capabilities
124-
- [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)
125-
- [spring-ai-examples - (community driven) Craig Walls ](https://github.com/habuma/spring-ai-examples)
126-
127-
### Workshops
128-
129-
- [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.
130-
- (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'
131-
132-
### Talks and Videos
133-
134-
Some selected videos. Search YouTube! for more.
135-
136-
- Spring AI: Seamlessly Integrating AI into Your Enterprise Java Applications (2024 - Devoxx.be)
137-
<br>[![Spring AI: Seamlessly Integrating AI into Your Enterprise Java Applications](https://img.youtube.com/vi/kfRyY0wsZHM/default.jpg)](https://youtu.be/kfRyY0wsZHM?si=qzIshk0GJqVTyrNm)
138-
139-
- Spring AI Is All You Need (2024 - GOTO Amsterdam)
140-
<br>[![Watch Spring Tips video](https://img.youtube.com/vi/vuhMti8B5H0/default.jpg)](https://youtu.be/vuhMti8B5H0?si=qhRVLh4-EaUhm9oe)
141-
142-
- Introducing Spring AI (2024 - Spring.IO)
143-
<br>[![Introducing Spring AI](https://img.youtube.com/vi/umKbaXsiCOY/default.jpg)](https://youtu.be/umKbaXsiCOY?si=FbqCtLIOgbihm6b6)
104+
To build with checkstyles enabled.
105+
Checkstyles are currently disabled, but you can enable them by doing the following:
106+
```shell
107+
./mvnw clean package -DskipTests -Ddisable.checks=false
108+
```
144109

145-
- Spring AI at Spring.IO Keynotes (2024 - Spring.IO)
146-
<br>[![Watch](https://img.youtube.com/vi/XUz4LKZx83g/default.jpg)](https://youtu.be/XUz4LKZx83g?t=2940)
147110

148-
- Spring Tips: Spring AI
149-
<br>[![Watch Spring Tips video](https://img.youtube.com/vi/aNKDoiOUo9M/default.jpg)](https://www.youtube.com/watch?v=aNKDoiOUo9M)
150-
* Overview of Spring AI @ Devoxx 2023
151-
<br>[![Watch the Devoxx 2023 video](https://img.youtube.com/vi/7OY9fKVxAFQ/default.jpg)](https://www.youtube.com/watch?v=7OY9fKVxAFQ)
152-
* Introducing Spring AI - Add Generative AI to your Spring Applications
153-
<br>[![Watch the video](https://img.youtube.com/vi/1g_wuincUdU/default.jpg)](https://www.youtube.com/watch?v=1g_wuincUdU)
154111

155-
- Spring AI Introduction: Building AI Applications in Java with Spring
156-
<br>[![Watch the video](https://img.youtube.com/vi/yyvjT0v3lpY/default.jpg)](https://www.youtube.com/watch?v=yyvjT0v3lpY&ab_channel=DanVega)

document-readers/markdown-reader/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<dependency>
4242
<groupId>org.springframework.ai</groupId>
4343
<artifactId>spring-ai-core</artifactId>
44-
<version>${parent.version}</version>
44+
<version>${project.parent.version}</version>
4545
</dependency>
4646

4747
<dependency>

document-readers/markdown-reader/src/main/java/org/springframework/ai/reader/markdown/MarkdownDocumentReader.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,27 @@ public class MarkdownDocumentReader implements DocumentReader {
6565
*/
6666
private final Parser parser;
6767

68+
/**
69+
* Create a new {@link MarkdownDocumentReader} instance.
70+
* @param markdownResource the resource to read
71+
*/
6872
public MarkdownDocumentReader(String markdownResource) {
6973
this(new DefaultResourceLoader().getResource(markdownResource), MarkdownDocumentReaderConfig.defaultConfig());
7074
}
7175

76+
/**
77+
* Create a new {@link MarkdownDocumentReader} instance.
78+
* @param markdownResource the resource to read
79+
* @param config the configuration to use
80+
*/
7281
public MarkdownDocumentReader(String markdownResource, MarkdownDocumentReaderConfig config) {
7382
this(new DefaultResourceLoader().getResource(markdownResource), config);
7483
}
7584

85+
/**
86+
* Create a new {@link MarkdownDocumentReader} instance.
87+
* @param markdownResource the resource to read
88+
*/
7689
public MarkdownDocumentReader(Resource markdownResource, MarkdownDocumentReaderConfig config) {
7790
this.markdownResource = markdownResource;
7891
this.config = config;
@@ -111,10 +124,13 @@ static class DocumentVisitor extends AbstractVisitor {
111124

112125
private Document.Builder currentDocumentBuilder;
113126

114-
public DocumentVisitor(MarkdownDocumentReaderConfig config) {
127+
DocumentVisitor(MarkdownDocumentReaderConfig config) {
115128
this.config = config;
116129
}
117130

131+
/**
132+
* Visits the document node and initializes the current document builder.
133+
*/
118134
@Override
119135
public void visit(org.commonmark.node.Document document) {
120136
this.currentDocumentBuilder = Document.builder();

document-readers/markdown-reader/src/main/java/org/springframework/ai/reader/markdown/config/MarkdownDocumentReaderConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static Builder builder() {
5656
return new Builder();
5757
}
5858

59-
public static class Builder {
59+
public static final class Builder {
6060

6161
private boolean horizontalRuleCreateDocument = false;
6262

document-readers/pdf-reader/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
<developerConnection>[email protected]:spring-projects/spring-ai.git</developerConnection>
3737
</scm>
3838

39+
<properties>
40+
</properties>
41+
3942
<dependencies>
4043
<dependency>
4144
<groupId>org.springframework.ai</groupId>
4245
<artifactId>spring-ai-core</artifactId>
43-
<version>${parent.version}</version>
46+
<version>${project.parent.version}</version>
4447
</dependency>
4548

4649
<dependency>

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.ai.reader.pdf;
1818

19-
import java.awt.*;
19+
import java.awt.Rectangle;
2020
import java.io.IOException;
2121
import java.util.ArrayList;
2222
import java.util.List;
@@ -112,7 +112,7 @@ public List<Document> get() {
112112
for (PDPage page : this.document.getDocumentCatalog().getPages()) {
113113
lastPage = page;
114114
if (counter % logFrequency == 0 && counter / logFrequency < 10) {
115-
this.logger.info("Processing PDF page: {}", (counter + 1));
115+
logger.info("Processing PDF page: {}", (counter + 1));
116116
}
117117
counter++;
118118

@@ -154,7 +154,7 @@ public List<Document> get() {
154154
readDocuments.add(toDocument(lastPage, pageTextGroupList.stream().collect(Collectors.joining()),
155155
startPageNumber, pageNumber));
156156
}
157-
this.logger.info("Processing {} pages", totalPages);
157+
logger.info("Processing {} pages", totalPages);
158158
return readDocuments;
159159

160160
}

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.ai.reader.pdf;
1818

19-
import java.awt.*;
19+
import java.awt.Rectangle;
2020
import java.util.ArrayList;
2121
import java.util.Iterator;
2222
import java.util.List;
@@ -133,7 +133,7 @@ public List<Document> get() {
133133
List<Document> documents = new ArrayList<>(paragraphs.size());
134134

135135
if (!CollectionUtils.isEmpty(paragraphs)) {
136-
this.logger.info("Start processing paragraphs from PDF");
136+
logger.info("Start processing paragraphs from PDF");
137137
Iterator<Paragraph> itr = paragraphs.iterator();
138138

139139
var current = itr.next();
@@ -152,7 +152,7 @@ public List<Document> get() {
152152
}
153153
}
154154
}
155-
this.logger.info("End processing paragraphs from PDF");
155+
logger.info("End processing paragraphs from PDF");
156156
return documents;
157157
}
158158

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/aot/PdfReaderRuntimeHints.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.springframework.aot.hint.RuntimeHints;
2323
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2424
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
25+
import org.springframework.lang.NonNull;
2526

2627
/**
2728
* The PdfReaderRuntimeHints class is responsible for registering runtime hints for PDFBox
@@ -34,7 +35,7 @@
3435
public class PdfReaderRuntimeHints implements RuntimeHintsRegistrar {
3536

3637
@Override
37-
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
38+
public void registerHints(@NonNull RuntimeHints hints, ClassLoader classLoader) {
3839
try {
3940

4041
var resolver = new PathMatchingResourcePatternResolver();
@@ -45,9 +46,11 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
4546
"/org/apache/pdfbox/resources/icc/**", "/org/apache/pdfbox/resources/text/**",
4647
"/org/apache/pdfbox/resources/ttf/**", "/org/apache/pdfbox/resources/version.properties");
4748

48-
for (var pattern : patterns)
49-
for (var resourceMatch : resolver.getResources(pattern))
49+
for (var pattern : patterns) {
50+
for (var resourceMatch : resolver.getResources(pattern)) {
5051
hints.resources().registerResource(resourceMatch);
52+
}
53+
}
5154

5255
}
5356
catch (IOException e) {

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/config/ParagraphManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ else if (paragraph.level() == level) {
184184
* @param level The TOC deepness level for this paragraph. The root is at level 0.
185185
* @param startPageNumber The page number in the PDF where this paragraph begins.
186186
* @param endPageNumber The page number in the PDF where this paragraph ends.
187+
* @param position The vertical position of the paragraph on the page.
187188
* @param children Sub-paragraphs for this paragraph.
188189
*/
189190
public record Paragraph(Paragraph parent, String title, int level, int startPageNumber, int endPageNumber,

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/config/PdfDocumentReaderConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @author Christian Tzolov
2929
*/
30-
public class PdfDocumentReaderConfig {
30+
public final class PdfDocumentReaderConfig {
3131

3232
public static final int ALL_PAGES = 0;
3333

@@ -65,7 +65,7 @@ public static PdfDocumentReaderConfig defaultConfig() {
6565
return builder().build();
6666
}
6767

68-
public static class Builder {
68+
public static final class Builder {
6969

7070
private int pagesPerDocument = 1;
7171

0 commit comments

Comments
 (0)