sema-upstash-vector 0.1.0
Store and search vector embeddings in an Upstash Vector database over its REST API
Exported declarations from this release. Parameter names and descriptions come directly from its source.
No matching exports. Try a function name or a word from its description.
(upstash-vector/client . opts)Build an Upstash Vector client map. Options: :url (default: UPSTASH_VECTOR_REST_URL env var — your index REST URL), :token (default: UPSTASH_VECTOR_REST_TOKEN env var), :timeout in ms (default 30000). Errors if the URL or token is missing.
View source definition
(define (upstash-vector/client . opts)
"Build an Upstash Vector client map. Options: :url (default: UPSTASH_VECTOR_REST_URL env var — your index REST URL), :token (default: UPSTASH_VECTOR_REST_TOKEN env var), :timeout in ms (default 30000). Errors if the URL or token is missing."
(let* ((o (if (null? opts) {} (first opts)))
(url (or (get o :url) (env "UPSTASH_VECTOR_REST_URL")))
(token (or (get o :token) (env "UPSTASH_VECTOR_REST_TOKEN"))))
(when (or (nil? url) (and (string? url) (string/empty? (string/trim url))))
(error "upstash-vector/client: no url — pass {:url \"https://xxx.upstash.io\"} or set the UPSTASH_VECTOR_REST_URL environment variable"))
(when (nil? token)
(error "upstash-vector/client: no token — pass {:token \"...\"} or set the UPSTASH_VECTOR_REST_TOKEN environment variable"))
{:url (string/chop-end url "/")
:token token
:timeout (get o :timeout 30000)}))(upstash-vector/delete! client ids . opts)Delete vectors by id. ids is a list of ids (strings or numbers). opts: :namespace (default ""). Returns a map with the number deleted ({:deleted N}).
View source definition
(define (upstash-vector/delete! client ids . opts)
"Delete vectors by id. ids is a list of ids (strings or numbers). opts: :namespace (default \"\"). Returns a map with the number deleted ({:deleted N})."
(let* ((o (if (null? opts) {} (first opts)))
(path (ns-path "/delete" (get o :namespace ""))))
(result client "DELETE" path {:ids ids})))(upstash-vector/fetch client ids . opts)Fetch vectors by id. ids is a list of ids (strings or numbers). opts: :include-metadata (default #t), :include-vectors (default #f), :include-data (default #f), :namespace (default ""). Returns a list of vectors (nil entries for ids not found).
View source definition
(define (upstash-vector/fetch client ids . opts)
"Fetch vectors by id. ids is a list of ids (strings or numbers). opts: :include-metadata (default #t), :include-vectors (default #f), :include-data (default #f), :namespace (default \"\"). Returns a list of vectors (nil entries for ids not found)."
(let* ((o (if (null? opts) {} (first opts)))
(body {:ids ids
:includeMetadata (get o :include-metadata #t)
:includeVectors (get o :include-vectors #f)
:includeData (get o :include-data #f)})
(path (ns-path "/fetch" (get o :namespace ""))))
(result client "POST" path body)))(upstash-vector/info client)Return index stats: vector count, pending count, dimension, similarity function, and per-namespace details.
View source definition
(define (upstash-vector/info client)
"Return index stats: vector count, pending count, dimension, similarity function, and per-namespace details."
(result client "GET" "/info" nil))(upstash-vector/query client vector . opts)Query for the nearest vectors to vector (a list of numbers). opts: :top-k (default 10), :include-metadata (default #t), :include-vectors (default #f), :include-data (default #f), :filter (a metadata filter string), :namespace (default ""). Returns a list of matches ({:id ... :score ... :metadata ...}).
View source definition
(define (upstash-vector/query client vector . opts)
"Query for the nearest vectors to vector (a list of numbers). opts: :top-k (default 10), :include-metadata (default #t), :include-vectors (default #f), :include-data (default #f), :filter (a metadata filter string), :namespace (default \"\"). Returns a list of matches ({:id ... :score ... :metadata ...})."
(let* ((o (if (null? opts) {} (first opts)))
(body0 {:vector vector
:topK (get o :top-k 10)
:includeMetadata (get o :include-metadata #t)
:includeVectors (get o :include-vectors #f)
:includeData (get o :include-data #f)})
(body (if (contains? o :filter) (assoc body0 :filter (get o :filter)) body0))
(path (ns-path "/query" (get o :namespace ""))))
(result client "POST" path body)))(upstash-vector/request client method path body)Make a raw Upstash Vector request. method is "GET"/"POST"/"DELETE", path an API path ("/query", "/upsert/my-namespace"). body is a map/list (sent as JSON) or nil. Returns the full decoded response map ({:result ...}); raises on non-2xx.
View source definition
(define (upstash-vector/request client method path body)
"Make a raw Upstash Vector request. method is \"GET\"/\"POST\"/\"DELETE\", path an API path (\"/query\", \"/upsert/my-namespace\"). body is a map/list (sent as JSON) or nil. Returns the full decoded response map ({:result ...}); raises on non-2xx."
(let* ((url (build-url client path))
(opts {:headers (client-headers client) :timeout (:timeout client)})
(resp (if (nil? body)
(http/request method url opts)
(http/request method url opts body)))
(status (:status resp)))
(if (and (>= status 200) (< status 300))
(decode-body (:body resp))
(error (format "upstash-vector: ~a ~a → ~a: ~a"
method path status (api-error-message (:body resp)))))))(upstash-vector/reset! client . opts)Delete every vector in a namespace. opts: :namespace (default "" = the default namespace). Returns "Success". Irreversible.
View source definition
(define (upstash-vector/reset! client . opts)
"Delete every vector in a namespace. opts: :namespace (default \"\" = the default namespace). Returns \"Success\". Irreversible."
(let* ((o (if (null? opts) {} (first opts)))
(path (ns-path "/reset" (get o :namespace ""))))
(result client "POST" path nil))))(upstash-vector/upsert! client vectors . opts)Insert or overwrite vectors. vectors is a map, or a list of maps, each with :id, :vector, and optional :metadata / :data. opts: :namespace (default ""). Returns Upstash's result ("Success").
View source definition
(define (upstash-vector/upsert! client vectors . opts)
"Insert or overwrite vectors. vectors is a map, or a list of maps, each with :id, :vector, and optional :metadata / :data. opts: :namespace (default \"\"). Returns Upstash's result (\"Success\")."
(let* ((o (if (null? opts) {} (first opts)))
(path (ns-path "/upsert" (get o :namespace ""))))
(result client "POST" path vectors)))About this reference
Generated with sema-reader 1.37.0 without executing package code. These are source declarations; dynamic exports, aliases, and runtime changes are not inferred.
Archive SHA-256 5a39b14746f9e067b9027f74cb8161f1b932e1e9367f2b770e7c943bdedc1714