Liking cljdoc? Tell your friends :D

supabase.storage.vector

Vector buckets, indexes, and vector data against Supabase Storage.

Provides vector bucket CRUD, per-bucket index operations, and per-index vector data operations (put, get, list, query, delete). Index ops take an instance returned by from; vector data ops take an instance further scoped by index.

Example

(require '[supabase.core.client :as client]
         '[supabase.storage.vector :as vector])

(def c (client/make-client "https://abc.supabase.co" "anon-key"))

(vector/create-bucket (vector/from c) "embeddings")

(def b (vector/from c "embeddings"))
(vector/create-index b {:index-name "docs"
                        :data-type :float32
                        :dimension 384
                        :distance-metric :cosine})

(def i (vector/index b "docs"))
(vector/put-vectors i [{:key "doc-1" :data {:float32 [0.1 0.2]}}])
(vector/query-vectors i {:query-vector {:float32 [0.1 0.2]} :top-k 5})

Each function returns {:status :body :headers} on success or an anomaly map on failure. All endpoints are POSTs under {storage-url}/vector with camelCase JSON bodies. See https://supabase.com/docs/reference/javascript/storage-vector-api

Vector buckets, indexes, and vector data against Supabase Storage.

Provides vector bucket CRUD, per-bucket index operations, and
per-index vector data operations (put, get, list, query, delete).
Index ops take an instance returned by `from`; vector data ops take an
instance further scoped by `index`.

## Example

    (require '[supabase.core.client :as client]
             '[supabase.storage.vector :as vector])

    (def c (client/make-client "https://abc.supabase.co" "anon-key"))

    (vector/create-bucket (vector/from c) "embeddings")

    (def b (vector/from c "embeddings"))
    (vector/create-index b {:index-name "docs"
                            :data-type :float32
                            :dimension 384
                            :distance-metric :cosine})

    (def i (vector/index b "docs"))
    (vector/put-vectors i [{:key "doc-1" :data {:float32 [0.1 0.2]}}])
    (vector/query-vectors i {:query-vector {:float32 [0.1 0.2]} :top-k 5})

Each function returns `{:status :body :headers}` on success or an anomaly
map on failure. All endpoints are POSTs under `{storage-url}/vector` with
camelCase JSON bodies. See
https://supabase.com/docs/reference/javascript/storage-vector-api
raw docstring

create-bucketclj

(create-bucket v name)

Creates a vector bucket named name.

Creates a vector bucket named `name`.
sourceraw docstring

create-indexclj

(create-index v params)

Creates a vector index within the instance's bucket.

Params

  • :index-name — unique name within the bucket (required)
  • :data-type:float32 (required, the only supported type)
  • :dimension — vector dimensionality, e.g. 384 (required)
  • :distance-metric:cosine, :euclidean, or :dotproduct (required)
  • :metadata-configuration — optional map with :non-filterable-metadata-keys
Creates a vector index within the instance's bucket.

## Params

* `:index-name` — unique name within the bucket (required)
* `:data-type` — `:float32` (required, the only supported type)
* `:dimension` — vector dimensionality, e.g. 384 (required)
* `:distance-metric` — `:cosine`, `:euclidean`, or `:dotproduct` (required)
* `:metadata-configuration` — optional map with
  `:non-filterable-metadata-keys`
sourceraw docstring

delete-bucketclj

(delete-bucket v name)

Deletes the vector bucket name. The bucket must be empty first.

Deletes the vector bucket `name`. The bucket must be empty first.
sourceraw docstring

delete-indexclj

(delete-index v index-name)

Deletes the index index-name and all its data from the instance's bucket.

Deletes the index `index-name` and all its data from the instance's
bucket.
sourceraw docstring

delete-vectorsclj

(delete-vectors v keys)

Deletes vectors by their keys in batch (1-500 per request).

Deletes vectors by their `keys` in batch (1-500 per request).
sourceraw docstring

fromclj

(from client)
(from client bucket-name)

Returns a vector storage instance, optionally bound to bucket-name. Bucket CRUD works on either form; index and vector data operations require the bound form.

(def v (from client "embeddings"))
(def i (index v "docs"))
Returns a vector storage instance, optionally bound to `bucket-name`.
Bucket CRUD works on either form; index and vector data operations
require the bound form.

    (def v (from client "embeddings"))
    (def i (index v "docs"))
sourceraw docstring

get-bucketclj

(get-bucket v name)

Retrieves metadata for the vector bucket name.

Retrieves metadata for the vector bucket `name`.
sourceraw docstring

get-indexclj

(get-index v index-name)

Retrieves metadata for the index index-name in the instance's bucket.

Retrieves metadata for the index `index-name` in the instance's bucket.
sourceraw docstring

get-vectorsclj

(get-vectors v opts)

Retrieves vectors by their keys in batch.

Options

  • :keys — vector keys to fetch (required)
  • :return-data — include vector data in the response
  • :return-metadata — include metadata in the response
Retrieves vectors by their `keys` in batch.

## Options

* `:keys` — vector keys to fetch (required)
* `:return-data` — include vector data in the response
* `:return-metadata` — include metadata in the response
sourceraw docstring

indexclj

(index v index-name)

Returns v scoped to index-name. Pass the result as the first argument to vector data operations.

Returns `v` scoped to `index-name`. Pass the result as the first
argument to vector data operations.
sourceraw docstring

list-bucketsclj

(list-buckets v)
(list-buckets v opts)

Lists vector buckets, optionally filtered and paginated.

Options

  • :prefix — name prefix filter
  • :max-results — page size (default 100)
  • :next-token — pagination token from a previous response
Lists vector buckets, optionally filtered and paginated.

## Options

* `:prefix` — name prefix filter
* `:max-results` — page size (default 100)
* `:next-token` — pagination token from a previous response
sourceraw docstring

list-indexesclj

(list-indexes v)
(list-indexes v opts)

Lists vector indexes in the instance's bucket. Options match list-buckets.

Lists vector indexes in the instance's bucket. Options match
`list-buckets`.
sourceraw docstring

list-vectorsclj

(list-vectors v)
(list-vectors v opts)

Lists vectors in the instance's index with pagination.

Options

  • :max-results — page size
  • :next-token — pagination token from a previous response
  • :return-data — include vector data in the response
  • :return-metadata — include metadata in the response
  • :segment-count — parallel scan segment count (1-16)
  • :segment-index — segment to return; with :segment-count given, must be within [0, segment-count)
Lists vectors in the instance's index with pagination.

## Options

* `:max-results` — page size
* `:next-token` — pagination token from a previous response
* `:return-data` — include vector data in the response
* `:return-metadata` — include metadata in the response
* `:segment-count` — parallel scan segment count (1-16)
* `:segment-index` — segment to return; with `:segment-count` given,
  must be within `[0, segment-count)`
sourceraw docstring

put-vectorsclj

(put-vectors v vectors)

Inserts or updates vectors in batch (1-500 per request).

Each vector is API-shaped and passed through as-is:

{:key "doc-1" :data {:float32 [0.1 0.2 ...]} :metadata {...}}
Inserts or updates `vectors` in batch (1-500 per request).

Each vector is API-shaped and passed through as-is:

    {:key "doc-1" :data {:float32 [0.1 0.2 ...]} :metadata {...}}
sourceraw docstring

query-vectorsclj

(query-vectors v query)

Queries for similar vectors using approximate nearest neighbor search.

Query

  • :query-vector{:float32 [...]} (required)
  • :top-k — number of nearest neighbors to return
  • :filter — metadata filter map
  • :return-distance — include distances in the response
  • :return-metadata — include metadata in the response
Queries for similar vectors using approximate nearest neighbor search.

## Query

* `:query-vector` — `{:float32 [...]}` (required)
* `:top-k` — number of nearest neighbors to return
* `:filter` — metadata filter map
* `:return-distance` — include distances in the response
* `:return-metadata` — include metadata in the response
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close