chroma

package
v0.5.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package chroma 提供 ChromaDB 向量数据库集成

ChromaDB 是一个开源的嵌入式向量数据库,专为 AI 应用设计。

特性:

  • 轻量级,易于嵌入
  • 支持本地和服务器模式
  • Python 友好
  • 简单的 API

使用示例:

store, err := chroma.NewStore(ctx,
    chroma.WithHost("localhost"),
    chroma.WithPort(8000),
    chroma.WithCollection("documents"),
)
defer store.Close()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option Store 配置选项

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey 设置 API Key

func WithCollection

func WithCollection(collection string) Option

WithCollection 设置集合名称

func WithDistanceMetric

func WithDistanceMetric(metric string) Option

WithDistanceMetric 设置距离度量

func WithHost

func WithHost(host string) Option

WithHost 设置主机地址

func WithPort

func WithPort(port int) Option

WithPort 设置端口

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store ChromaDB 向量存储

通过 HTTP API 与 ChromaDB 服务器交互

func NewStore

func NewStore(ctx context.Context, opts ...Option) (*Store, error)

NewStore 创建 ChromaDB 向量存储

func (*Store) Add

func (s *Store) Add(ctx context.Context, docs []vector.Document) error

Add 添加文档

func (*Store) Clear

func (s *Store) Clear(ctx context.Context) error

Clear 清空所有文档

func (*Store) Close

func (s *Store) Close() error

Close 关闭连接

func (*Store) Count

func (s *Store) Count(ctx context.Context) (int, error)

Count 统计文档数量

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, ids []string) error

Delete 删除文档

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*vector.Document, error)

Get 获取文档

func (*Store) Search

func (s *Store) Search(ctx context.Context, embedding []float32, limit int, opts ...vector.SearchOption) ([]vector.Document, error)

Search 搜索相似文档

func (*Store) Stats

func (s *Store) Stats(ctx context.Context) (map[string]any, error)

Stats 获取统计信息

func (*Store) Update

func (s *Store) Update(ctx context.Context, docs []vector.Document) error

Update 更新文档

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL