Files
landing_page/qdrant-landing/content/documentation/frameworks/spring-ai.md
T
Anush f261124e9c docs: Added Spring AI integration (#650)
* docs: Added Spring AI integration

* chore: updated snippets spring-ai.md
2024-03-13 12:38:42 +05:30

2.0 KiB

title, weight
title weight
Spring AI 2200

Spring AI

Spring AI is a Java framework that provides a Spring-friendly API and abstractions for developing AI applications.

Qdrant is available as supported vector database for use within your Spring AI projects.

Installation

To acquire Spring AI artifacts, declare the Spring Snapshot repository in your pom.xml.

<repository>
   <id>spring-snapshots</id>
   <name>Spring Snapshots</name>
   <url>https://repo.spring.io/snapshot</url>
   <releases>
      <enabled>false</enabled>
   </releases>
</repository>

Add the spring-ai-qdrant package.

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-qdrant</artifactId>
    <version>VERSION</version>
</dependency>

Usage

You can set up the Qdrant vector store with the QdrantVectorStoreConfig options.

@Bean
public QdrantVectorStoreConfig qdrantVectorStoreConfig() {

    return QdrantVectorStoreConfig.builder()
        .withHost("<QDRANT_HOSTNAME>")
        .withPort(<QDRANT_GRPC_PORT>)
        .withCollectionName("<QDRANT_COLLECTION_NAME>")
        .withApiKey("<QDRANT_API_KEY>")
        .build();
}

Build the vector store using the config and any of the support Spring AI embedding providers.

@Bean
public VectorStore vectorStore(QdrantVectorStoreConfig config, EmbeddingClient embeddingClient) {
    return new QdrantVectorStore(config, embeddingClient);
}

You can now use the VectorStore instance backed by Qdrant as a vector store in the Spring AI APIs.

Further Reading