client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRecordsRequest

type AddRecordsRequest struct {
	IDs        []string         `json:"ids"`
	Documents  []string         `json:"documents"`
	Embeddings [][]float32      `json:"embeddings"` // Change: No longer omitempty
	Metadatas  []map[string]any `json:"metadatas,omitempty"`
}

type ChromaClient

type ChromaClient struct {
	URL, Tenant, Database string

	Embedder onnx.EmbedderInterface
	// contains filtered or unexported fields
}

func NewChromaDBClient

func NewChromaDBClient(url, tenant, database string) *ChromaClient

func (*ChromaClient) AddBatch

func (c *ChromaClient) AddBatch(collectionID string, docs []string, ids []string) error

func (*ChromaClient) AddBatchGeneric

func (c *ChromaClient) AddBatchGeneric(collectionID string, documents []string, ids []string, metadatas []map[string]any) error

AddBatchGeneric handles documents, IDs, and dynamic metadata maps.

func (*ChromaClient) AddDocument

func (c *ChromaClient) AddDocument(collectionID, id, text string, vector []float32) error

AddDocument - Corrected Metadata tag handling

func (*ChromaClient) CreateCollection

func (c *ChromaClient) CreateCollection(name string) (string, error)

func (*ChromaClient) CreateDatabase

func (c *ChromaClient) CreateDatabase(name string) error

CreateDatabase creates a new database in the current tenant.

func (*ChromaClient) DeleteCollection

func (c *ChromaClient) DeleteCollection(name string) error

func (*ChromaClient) DeleteRecords

func (c *ChromaClient) DeleteRecords(collectionID string, ids []string) error

DeleteRecords removes specific documents from a collection by their IDs.

func (*ChromaClient) GenerateLocalEmbedding

func (c *ChromaClient) GenerateLocalEmbedding(text string) ([]float32, error)

Simplified logic for what your Go function will do:

func (*ChromaClient) GetIDByName

func (c *ChromaClient) GetIDByName(name string) (string, error)

func (*ChromaClient) GetTenant

func (c *ChromaClient) GetTenant() (bool, error)

func (*ChromaClient) ListCollections

func (c *ChromaClient) ListCollections() ([]Collection, error)

func (*ChromaClient) ListDatabases

func (c *ChromaClient) ListDatabases() ([]Database, error)

func (*ChromaClient) ListDocuments

func (c *ChromaClient) ListDocuments(collectionID string) (*GetRecordsResponse, error)

ListDocuments - List Documents in collection

func (*ChromaClient) QueryBatch

func (c *ChromaClient) QueryBatch(collectionId string, queryTexts []string, nResults int) (*QueryResponse, error)

func (*ChromaClient) ResolveCollectionID

func (c *ChromaClient) ResolveCollectionID(input string) (string, error)

func (*ChromaClient) TestConnection

func (c *ChromaClient) TestConnection() error

func (*ChromaClient) UpsertBatchGeneric

func (c *ChromaClient) UpsertBatchGeneric(collectionID string, documents []string, ids []string, metadatas []map[string]any) error

UpsertBatchGeneric handles documents, IDs, and dynamic metadata maps for upserting (insert or update).

type ChromaClientInterface

type ChromaClientInterface interface {
	TestConnection() error
	GetTenant() (bool, error)
	ListDatabases() ([]Database, error)
	CreateDatabase(name string) error
	ListCollections() ([]Collection, error)
	AddBatch(collectionID string, docs []string, ids []string) error
	AddBatchGeneric(collectionID string, documents []string, ids []string, metadatas []map[string]any) error
	UpsertBatchGeneric(collectionID string, documents []string, ids []string, metadatas []map[string]any) error
	QueryBatch(collectionId string, queryTexts []string, nResults int) (*QueryResponse, error)
	GetIDByName(name string) (string, error)
	ResolveCollectionID(input string) (string, error)
	DeleteCollection(name string) error
	DeleteRecords(collectionID string, ids []string) error
}

type Collection

type Collection struct {
	ID        string         `json:"id"`
	Name      string         `json:"name"`
	Tenant    string         `json:"tenant"`
	Database  string         `json:"database"`
	Metadata  map[string]any `json:"metadata"`
	Dimension *int           `json:"dimension"` // Pointer because it can be null
	Config    map[string]any `json:"configuration_json"`
}

Collection represents the detailed response from ChromaDB

type CreateCollectionRequest

type CreateCollectionRequest struct {
	Name        string         `json:"name"`
	Metadata    map[string]any `json:"metadata"`
	GetOrCreate bool           `json:"get_or_create"`
}

type Database

type Database struct {
	Id     string `json:"id"`
	Name   string `json:"name"`
	Tenant string `json:"tenant"`
}

type GetRecordsRequest

type GetRecordsRequest struct {
	Tenant   string   `json:"tenant"`
	Database string   `json:"database"`
	IDs      []string `json:"ids,omitempty"`
	Include  []string `json:"include"`
	Limit    *int     `json:"limit"`
	Offset   *int     `json:"offset"`
}

type GetRecordsResponse

type GetRecordsResponse struct {
	IDs       []string         `json:"ids"`
	Documents []string         `json:"documents"`
	Metadatas []map[string]any `json:"metadatas"`
}

type IngestRecord

type IngestRecord struct {
	ID       string         `json:"id"`
	Text     string         `json:"text"`
	Metadata map[string]any `json:"metadata"`
}

type QueryResponse

type QueryResponse struct {
	IDs       [][]string         `json:"ids"`
	Documents [][]string         `json:"documents"`
	Metadatas [][]map[string]any `json:"metadatas"`
	Distances [][]float32        `json:"distances"`
}

Jump to

Keyboard shortcuts

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