跳到主要内容

Chroma

捆绑包 (Bundles) 包含支持 Langflow 与特定第三方集成自定义组件。

本页面介绍了 Chroma 捆绑包中可用的组件。

Chroma DB

您可以使用 Chroma DB 组件,通过 Chroma 向量存储实例读写 Chroma 数据库。 包括对具有或不具有持久性的远程或内存实例的支持。

关于向量存储实例

Because Langflow is based on LangChain, vector store components use an instance of LangChain vector store to drive the underlying read and write functions. These instances are provider-specific and configured according to the component's parameters, such as the connection string, index name, and schema.

In component code, this is often instantiated as vector_store, but some vector store components use a different name, such as the provider name.

Some LangChain classes don't expose all possible options as component parameters. Depending on the provider, these options might use default values or allow modification through environment variables, if they are supported in Langflow. For information about specific options, see the LangChain API reference and vector store provider's documentation.

写入时,组件可以在指定位置创建新的数据库或集合。

提示

短暂的(非持久的)本地 Chroma 向量存储对于测试不需要保留数据库的向量搜索流非常有帮助。

If you use a vector store component to query your vector database, it produces search results that you can pass to downstream components in your flow as a list of Data objects or a tabular DataFrame. If both types are supported, you can set the format near the vector store component's output port in the visual editor.

在流中使用 Chroma DB 组件

以下示例流使用一个 Chroma DB 组件进行读写:

ChromaDB 接收分割文本

  • 写入时,它将来自 URL 组件Data 分割成块,使用附加的 嵌入模型 (Embedding Model) 组件计算嵌入,然后将块和嵌入加载到 Chroma 向量存储中。 要触发写入,请在 Chroma DB 组件上点击 运行组件 (Run component)

  • 读取时,它使用聊天输入对向量存储执行相似性搜索,然后将搜索结果打印到聊天中。 要触发读取,请打开 游乐场 (Playground) 并输入聊天消息。

运行一次流后,您可以点击每个组件上的 检查输出 (Inspect Output),以了解数据在从一个组件传递到另一个组件时是如何转换的。

Chroma DB 参数

您可以检查向量存储组件的参数,以了解更多关于它接受的输入、支持的功能以及如何配置它的信息。

Some parameters are hidden by default in the visual editor. You can modify all parameters through the Controls in the component's header menu.

Some parameters are conditional, and they are only available after you set other parameters or select specific options for other parameters. Conditional parameters may not be visible on the Controls pane until you set the required dependencies.

有关接受的值和功能的信息,请参阅提供商的文档或检查 组件代码

名称类型描述
集合名称 (collection_name)String输入参数。您的 Chroma 向量存储集合的名称。默认值:langflow
持久化目录 (persist_directory)String输入参数。要持久化 Chroma 数据库,请输入存储 chroma.sqlite3 文件的目录的相对或绝对路径。对于临时数据库,请留空。读写现有的持久化数据库时,请指定持久化目录的路径。
摄取数据 (ingest_data)Data or DataFrame输入参数。包含要写入向量存储的记录的 DataDataFrame 输入。仅与写入相关。
搜索查询 (search_query)String输入参数。用于向量搜索的查询。仅与读取相关。
缓存向量存储 (cache_vector_store)Boolean输入参数。如果为 true,组件将在内存中缓存向量存储以实现更快的读取。默认值:启用 (true)。
嵌入 (embedding)Embeddings输入参数。用于向量存储的嵌入函数。默认情况下,Chroma DB 使用其内置的嵌入模型,或者您可以附加 嵌入模型 (Embedding Model) 组件以使用不同的提供商或模型。
CORS 允许来源 (chroma_server_cors_allow_origins)String输入参数。Chroma 服务器允许的 CORS 来源。
Chroma 服务器主机 (chroma_server_host)String输入参数。Chroma 服务器的主机。
Chroma 服务器 HTTP 端口 (chroma_server_http_port)Integer输入参数。Chroma 服务器的 HTTP 端口。
Chroma 服务器 gRPC 端口 (chroma_server_grpc_port)Integer输入参数。Chroma 服务器的 gRPC 端口。
Chroma 服务器 SSL 已启用 (chroma_server_ssl_enabled)Boolean输入参数。为 Chroma 服务器启用 SSL。
允许重复 (allow_duplicates)Boolean输入参数。如果为 true(默认),写入时不会检查集合中是否存在重复项,从而允许您存储相同内容的多个副本。如果为 false,写入时不会添加与集合中已存在文档匹配的文档。如果为 false,它可以通过搜索整个集合或仅搜索 limit 中指定的记录数量来严格执行去重。仅与写入相关。
搜索类型 (search_type)String输入参数。要执行的搜索类型,即 SimilarityMMR。仅与读取相关。
结果数量 (number_of_results)Integer输入参数。要返回的搜索结果数量。默认值:10。仅与读取相关。
限制 (limit)Integer输入参数。当 允许重复false 时,限制要比较的记录数量。这有助于提高向大型集合写入时的性能,但可能会导致一些重复记录。仅与写入相关。

另请参阅

Search