XU XUv0.8.8
中文

API

#github.com/xulang-org/packages/chroma

import: chroma #github.com/xulang-org/packages/chroma

counts: 3 fns, 16 methods, 3 types, 0 consts, 0 ifaces

Chroma AI Vector Database Client for Xu Supports collection management, document and vector embedding storage, and similarity search.

github.com/xulang-org/packages · 0.1.1 · Install and use

struct Response

XuAPI
pub struct Response {
    pub status_code int
    pub headers string
    pub body string
}

Purpose

Public struct `Response`.

Parameters

status_code int
field (int)
headers string
field (string)
body string
body

struct Client

XuAPI
pub struct Client {
    pub host string
    pub port int
    pub tenant string
    pub database string
}

Purpose

Public struct `Client`.

Parameters

host string
host
port int
port
tenant string
field (string)
database string
field (string)

new_client

XuAPI
pub fn new_client(endpoint string) Client

Purpose

Construct client.

Parameters

endpoint string
endpoint (string)

Returns

Client — a value of this type

(Client) request

XuAPI
pub fn (c Client) request(method string, path string, body string) Response

Purpose

Call `request` on `Client`. Throws on failure.

Parameters

c Client
receiver Client (value receiver)
method string
method (string)
path string
filesystem path (string)
body string
body (string)

Returns

Response — a value of this type

(Client) heartbeat

XuAPI
pub fn (c Client) heartbeat() bool

Purpose

Call `heartbeat` on `Client`.

Parameters

c Client
receiver Client (value receiver)

Returns

bool — true or false

(Client) create_collection

XuAPI
pub fn (c Client) create_collection(name string) string

Purpose

Method on `Client`: create collection. Throws on failure.

Parameters

c Client
receiver Client (value receiver)
name string
name (string)

Returns

string — result string

(Client) add

XuAPI
pub fn (c Client) add(col_id string, ids_json string, embeddings_json string, documents_json string) bool

Purpose

Method on `Client`: add.

Parameters

c Client
receiver Client (value receiver)
col_id string
col_id (string)
ids_json string
ids_json (string)
embeddings_json string
embeddings_json (string)
documents_json string
documents_json (string)

Returns

bool — true or false

(Client) query

XuAPI
pub fn (c Client) query(col_id string, query_embeddings_json string, n_results int) string

Purpose

Call `query` on `Client`. Throws on failure.

Parameters

c Client
receiver Client (value receiver)
col_id string
col_id (string)
query_embeddings_json string
query_embeddings_json (string)
n_results int
n_results (int)

Returns

string — result string

(Client) delete_collection

XuAPI
pub fn (c Client) delete_collection(name string) bool

Purpose

Method on `Client`: delete collection.

Parameters

c Client
receiver Client (value receiver)
name string
name (string)

Returns

bool — true or false

struct Pool

XuAPI
pub struct Pool {
    pub client Client
    pub state chan pool.State
    pub max_idle int
}

Purpose

Public struct `Pool`.

Parameters

client Client
field (Client)
state chan pool.State
field (channel; type chan pool.State)
max_idle int
field (int)

new_pool

XuAPI
pub fn new_pool(endpoint string, max_idle int) Pool

Purpose

Construct pool.

Parameters

endpoint string
endpoint (string)
max_idle int
max_idle (int)

Returns

Pool — a value of this type

(&Pool) dup

XuAPI
pub fn (p &Pool) dup() Pool

Purpose

Copies configuration while sharing the connection and close lifecycle.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

Pool — a value of this type

(&Pool) get_conn

XuAPI
pub fn (p &Pool) get_conn() int

Purpose

Method on `&Pool`: read conn.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

int — a value of this type

(&Pool) put_conn

XuAPI
pub fn (p &Pool) put_conn(fd int)

Purpose

Method on `&Pool`: put connection.

Parameters

p &Pool
receiver &Pool (borrow)
fd int
file descriptor (int)

(&Pool) discard_conn

XuAPI
pub fn (p &Pool) discard_conn(fd int)

Purpose

Method on `&Pool`: discard connection.

Parameters

p &Pool
receiver &Pool (borrow)
fd int
file descriptor (int)

open_pool

XuAPI
pub fn open_pool(endpoint string, max_idle int) Pool

Purpose

Open pool.

Parameters

endpoint string
endpoint (string)
max_idle int
max_idle (int)

Returns

Pool — a value of this type

(&Pool) heartbeat

XuAPI
pub fn (p &Pool) heartbeat() bool

Purpose

Call `heartbeat` on `&Pool`.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

bool — true or false

(&Pool) create_collection

XuAPI
pub fn (p &Pool) create_collection(name string) string

Purpose

Method on `&Pool`: create collection. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
name string
name (string)

Returns

string — result string

(&Pool) add

XuAPI
pub fn (p &Pool) add(col_id string, ids_json string, embeddings_json string, documents_json string) bool

Purpose

Method on `&Pool`: add.

Parameters

p &Pool
receiver &Pool (borrow)
col_id string
col_id (string)
ids_json string
ids_json (string)
embeddings_json string
embeddings_json (string)
documents_json string
documents_json (string)

Returns

bool — true or false

(&Pool) query

XuAPI
pub fn (p &Pool) query(col_id string, query_embeddings_json string, n_results int) string

Purpose

Call `query` on `&Pool`. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
col_id string
col_id (string)
query_embeddings_json string
query_embeddings_json (string)
n_results int
n_results (int)

Returns

string — result string

(&Pool) delete_collection

XuAPI
pub fn (p &Pool) delete_collection(name string) bool

Purpose

Method on `&Pool`: delete collection.

Parameters

p &Pool
receiver &Pool (borrow)
name string
name (string)

Returns

bool — true or false

(&Pool) close

XuAPI
pub fn (p &Pool) close()

Purpose

Method on `&Pool`: close the resource.

Parameters

p &Pool
receiver &Pool (borrow)