主题
Azure CosmosDB Mongo vCore
https://azure.microsoft.com/en-us/products/cosmos-db/
已弃用 —— 更名为 Azure DocumentDB
Microsoft 已将 Azure CosmosDB for MongoDB vCore 重塑品牌为 Azure DocumentDB(参见 https://learn.microsoft.com/en-us/azure/documentdb/)。
本模块已弃用,改用 Azure DocumentDB 集成。 旧模块及其 Spring Boot starter 仍保留,以维持向后兼容。 新项目应使用 DocumentDB 集成;现有项目可 遵循迁移指南。
Maven 依赖
你可以在纯 Java 或 Spring Boot 应用中使用 Azure CosmosDB Mongo vCore 与 LangChain4j。
纯 Java
xml
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-azure-cosmos-mongo-vcore</artifactId>
<version>1.22.0-beta32</version>
</dependency>1
2
3
4
5
2
3
4
5
Spring Boot
Spring Boot 3:
xml
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-azure-cosmos-mongo-vcore-spring-boot-starter</artifactId>
<version>${latest version here}</version>
</dependency>1
2
3
4
5
2
3
4
5
对于 Spring Boot 4,请改用 langchain4j-azure-cosmos-mongo-vcore-spring-boot4-starter, 配置属性与下方相同。
然后在你的 application.properties 或 application.yml 中配置嵌入存储:
properties
langchain4j.azure.cosmos-mongo-vcore.connection-string=${AZURE_COSMOS_CONNECTION_STRING}
langchain4j.azure.cosmos-mongo-vcore.database-name=my-database
langchain4j.azure.cosmos-mongo-vcore.collection-name=my-collection
langchain4j.azure.cosmos-mongo-vcore.index-name=my-index
langchain4j.azure.cosmos-mongo-vcore.create-index=true
langchain4j.azure.cosmos-mongo-vcore.dimensions=1536
langchain4j.azure.cosmos-mongo-vcore.kind=vector-hnsw
langchain4j.azure.cosmos-mongo-vcore.m=16
langchain4j.azure.cosmos-mongo-vcore.ef-construction=64
langchain4j.azure.cosmos-mongo-vcore.ef-search=401
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
AzureCosmosDbMongoVCoreEmbeddingStore bean 会被自动创建并可被注入:
java
@Autowired
AzureCosmosDbMongoVCoreEmbeddingStore embeddingStore;1
2
2
API
AzureCosmosDbMongoVCoreEmbeddingStore