这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@
<module>spring-actuator</module>
<module>spring-ai</module>
<module>spring-ai-2</module>
<module>spring-ai-3</module>
<module>spring-ai-3</module>
<module>spring-aop</module>
<module>spring-aop-2</module>
<module>spring-batch</module>
Expand Down Expand Up @@ -1150,7 +1150,7 @@
<module>spring-actuator</module>
<module>spring-ai</module>
<module>spring-ai-2</module>
<module>spring-ai-3</module>
<module>spring-ai-3</module>
<module>spring-aop</module>
<module>spring-aop-2</module>
<module>spring-batch</module>
Expand Down
2 changes: 2 additions & 0 deletions spring-ai-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Relevant Articles

2 changes: 2 additions & 0 deletions spring-ai-3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Relevant Articles
- [Building a RAG App Using MongoDB and Spring AI](https://www.baeldung.com/spring-ai-mongodb-rag)
29 changes: 29 additions & 0 deletions spring-ai-3/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
postgres:
image: pgvector/pgvector:pg17
environment:
POSTGRES_DB: vectordb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5434:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 10s
timeout: 5s
retries: 5

ollama:
image: ollama/ollama:latest
ports:
- "11435:11434"
volumes:
- ollama_data:/root/.ollama
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:11435/api/health" ]
interval: 10s
timeout: 5s
retries: 10

volumes:
ollama_data:
154 changes: 150 additions & 4 deletions spring-ai-3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,72 @@
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-markdown-document-reader</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mcp-server-webmvc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-chroma-store-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-anthropic-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bedrock-converse-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
<version>${spring-ai.version}</version>
<version>${spring-ai-start-model-openai.version}</version>
</dependency>

<!-- Test dependencies -->
Expand All @@ -43,14 +100,99 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>chromadb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>ollama</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<version>${spring-boot-docker-compose.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-mongodb-atlas</artifactId>
<version>${spring-ai-mongodb-atlas.version}</version>
</dependency>
</dependencies>

<profiles>
<profile>
<id>transcribe</id>
<id>chromadb</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.boot.mainclass>com.baeldung.springai.chromadb.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>assistant</id>
<properties>
<spring.boot.mainclass>com.baeldung.spring.ai.om.OrderManagementApplication</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>anthropic</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.anthropic.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>deepseek</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.deepseek.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>evaluator</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.evaluator.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>hugging-face</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.huggingface.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>mcp-server</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.mcp.server.ServerApplication</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>mcp-client</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.mcp.client.ClientApplication</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>amazon-nova</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.nova.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>pgvector</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.semanticsearch.Application</spring.boot.mainclass>
</properties>
</profile>
<profile>
<id>transcribe</id>
<properties>
<spring.boot.mainclass>com.baeldung.springai.transcribe.Application</spring.boot.mainclass>
</properties>
Expand All @@ -77,8 +219,12 @@
</build>

<properties>
<spring-ai-mongodb-atlas.version>1.0.0-M7</spring-ai-mongodb-atlas.version>
<junit-jupiter.version>5.9.0</junit-jupiter.version>
<spring-boot-docker-compose.version>3.1.1</spring-boot-docker-compose.version>
<spring-boot.version>3.4.5</spring-boot.version>
<spring-ai.version>1.0.0-M7</spring-ai.version>
<spring-ai.version>1.0.0-M6</spring-ai.version>
<spring-ai-start-model-openai.version>1.0.0-M7</spring-ai-start-model-openai.version>
</properties>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class AdvisorConfiguration {

@Bean
public QuestionAnswerAdvisor questionAnswerAdvisor(VectorStore vectorStore) {
return new QuestionAnswerAdvisor(vectorStore, SearchRequest.defaults());
return new QuestionAnswerAdvisor(vectorStore, SearchRequest.builder().build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public void saveWikiDocument(WikiDocument wikiDocument) {
public List<WikiDocument> findSimilarDocuments(String searchText) {

return vectorStore
.similaritySearch(SearchRequest
.similaritySearch(SearchRequest.builder()
.query(searchText)
.withSimilarityThreshold(0.87)
.withTopK(10))
.similarityThreshold(0.87)
.topK(10).build())
.stream()
.map(document -> {
WikiDocument wikiDocument = new WikiDocument();
wikiDocument.setFilePath((String) document
.getMetadata().get("filePath"));
wikiDocument.setContent(document.getContent());
wikiDocument.setContent(document.getText());

return wikiDocument;
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.baeldung.springai.rag.mongodb.config;

import org.springframework.ai.autoconfigure.vectorstore.mongo.MongoDBAtlasVectorStoreProperties;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.mongodb.atlas.MongoDBAtlasVectorStore;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.MongoTemplate;

@Configuration
public class VectorStoreConfig {
@Bean
public MongoDBAtlasVectorStore vectorStore(MongoTemplate mongoTemplate,
@Qualifier("openAiEmbeddingModel") EmbeddingModel embeddingModel,
MongoDBAtlasVectorStoreProperties properties) {

return MongoDBAtlasVectorStore.builder(mongoTemplate, embeddingModel)
.collectionName(properties.getCollectionName())
.pathName(properties.getPathName())
.vectorIndexName(properties.getIndexName())
.initializeSchema(properties.isInitializeSchema())
.build();
}
}
1 change: 0 additions & 1 deletion spring-ai/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Relevant Articles
- [Introduction to Spring AI](https://www.baeldung.com/spring-ai)
- [A Guide to Structured Output in Spring AI](https://www.baeldung.com/spring-artificial-intelligence-structure-output)
- [Building a RAG App Using MongoDB and Spring AI](https://www.baeldung.com/spring-ai-mongodb-rag)
- [Create a RAG (Retrieval Augmented Generation) Application with Redis and Spring AI](https://www.baeldung.com/spring-ai-redis-rag-app)
- [Create a ChatGPT Like Chatbot With Ollama and Spring AI](https://www.baeldung.com/spring-ai-ollama-chatgpt-like-chatbot)
- [Function Calling in Java and Spring AI Using the Mistral AI API](https://www.baeldung.com/spring-ai-mistral-api-function-calling)
Expand Down
4 changes: 0 additions & 4 deletions spring-ai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-pdf-document-reader</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mongodb-atlas-store-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
Expand Down

This file was deleted.