Skip to content
LangChain4j 文档版本 1.22.0 源快照 e259f7c2 更新于 2026-10-14

Azure CosmosDB NoSQL

https://azure.microsoft.com/en-us/products/cosmos-db/

Maven 依赖

你可以在纯 Java 或 Spring Boot 应用中使用 Azure CosmosDB NoSQL 与 LangChain4j。

纯 Java

xml
<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-azure-cosmos-nosql</artifactId>
    <version>1.22.0-beta32</version>
</dependency>

Spring Boot

Spring Boot 3:

xml
<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-azure-cosmos-nosql-spring-boot-starter</artifactId>
    <version>${latest version here}</version>
</dependency>

对于 Spring Boot 4,请改用 langchain4j-azure-cosmos-nosql-spring-boot4-starter, 配置属性与下方相同。

然后在你的 application.properties 或 application.yml 中配置嵌入存储:

properties
langchain4j.azure.cosmos-nosql.endpoint=${AZURE_COSMOS_ENDPOINT}
langchain4j.azure.cosmos-nosql.key=${AZURE_COSMOS_KEY}
langchain4j.azure.cosmos-nosql.database-name=my-database
langchain4j.azure.cosmos-nosql.container-name=my-container
langchain4j.azure.cosmos-nosql.dimensions=1536

请将 dimensions 设置为与你的嵌入模型相符。只有在存在一个可供 starter 推断维度的 EmbeddingModel bean 时,才可省略它。

AzureCosmosDbNoSqlEmbeddingStore bean 会被自动创建并可被注入:

java
@Autowired
AzureCosmosDbNoSqlEmbeddingStore embeddingStore;

API

  • AzureCosmosDbNoSqlEmbeddingStore

示例

BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。