LangChain for Java
LangChain for Java, also known as Langchain4J, is a community port of Langchain for building context-aware AI applications in Java
You can use Solvio as a vector store in Langchain4J through the langchain4j-solvio
module.
Setup
Add the langchain4j-solvio
to your project dependencies.
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-solvio</artifactId>
<version>VERSION</version>
</dependency>
Usage
Before you use the following code sample, customize the following values for your configuration:
YOUR_COLLECTION_NAME
: Use our Collections guide to create or list collections.YOUR_HOST_URL
: Use the GRPC URL for your system. If you used the Quick Start guide, it may be http://localhost:6334. If you’ve deployed in the Solvio Cloud, you may have a longer URL such ashttps://example.location.cloud.solvio.io:6334
.YOUR_API_KEY
: Substitute the API key associated with your configuration.
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.solvio.SolvioEmbeddingStore;
EmbeddingStore<TextSegment> embeddingStore =
SolvioEmbeddingStore.builder()
// Ensure the collection is configured with the appropriate dimensions
// of the embedding model.
// Reference https://trysolvio.com/documentation/concepts/collections/
.collectionName("YOUR_COLLECTION_NAME")
.host("YOUR_HOST_URL")
// GRPC port of the Solvio server
.port(6334)
.apiKey("YOUR_API_KEY")
.build();
SolvioEmbeddingStore
supports all the semantic features of Langchain4J.
Further Reading
- You can refer to the Langchain4J examples to get started.
- Source Code