GithubHelp home page GithubHelp logo

vdaas / vald-client-clj Goto Github PK

View Code? Open in Web Editor NEW
12.0 6.0 2.0 196 KB

A Clojure gRPC client library for Vald / valdcli is a CLI client tool for Vald.

Home Page: https://clojars.org/vald-client-clj

License: Apache License 2.0

Clojure 95.54% Makefile 4.34% Dockerfile 0.13%
vald

vald-client-clj's Introduction

vald-client-clj / valdcli

LICENSE release Clojars Project Vald version clojure

A Clojure gRPC client library for Vald.

Usage

To use this library, one of the following libraries is required.

  • io.grpc/grpc-okhttp
  • io.grpc/grpc-netty
  • io.grpc/grpc-netty-shaded
(require '[vald-client-clj.core :as vald])

;; vald gateway
(def client
  (vald/vald-client "localhost" 8081))

(-> client
    (vald/stream-insert
      println
      [{:id "meta1"
        :vector [0.1 0.2 0.3 0.4 0.5 0.6]}
       {:id "meta2"
        :vector [0.2 0.2 0.2 0.2 0.2 0.2]}])
    (deref))

(-> client
    (vald/get-object "meta1"))

(-> client
    (vald/stream-search-by-id println {:num 2} ["meta1" "meta2"])
    (deref))

(-> client
    (vald/search {:num 2} [0.1 0.2 0.3 0.3 0.3 0.4]))

(vald/close client)

valdcli

valdcli is a CLI tool built from vald-client-clj.

Fast startup time powered by GraalVM.

Install

Native binaries are available from the latest release.

Usage

$ valdcli --help
Usage: valdcli [OPTIONS] ACTION

Options:
      --help                  show usage
      --version               show version
  -d, --debug                 debug mode
  -p, --port PORT  8080       Port number
  -h, --host HOST  localhost  Hostname

Actions:
  create-and-save-index Call create-and-save-index command. (only for Agent)
  create-index          Call create-index command. (only for Agent)
  exists                Check whether ID exists or not.
  get-object            Get object info of single ID.
  index-info            Fetch index info. (only for Agent)
  insert                Insert single vector.
  rand-vec              Prints randomized vector.
  rand-vecs             Prints randomized vectors.
  remove                Remove single ID.
  save-index            Call save-index command. (only for Agent)
  search                Search single vector.
  search-by-id          Search vectors using single ID.
  stream-get-object     Get object info of multiple IDs.
  stream-insert         Insert multiple vectors.
  stream-remove         Remove multiple IDs.
  stream-search         Search multiple vectors.
  stream-search-by-id   Search vectors using multiple IDs.
  stream-update         Update multiple vectors.
  update                Update single vector.

It supports both EDN and JSON format data.

insert

## insert EDN formatted vector
$ valdcli insert abc "[0.1 0.2 0.3 0.4 0.5 0.6]"

## it supports to read stdin
$ echo "[0.1 0.2 0.3 0.4 0.5 0.6]" | valdcli -p 8081 insert abc

## by adding '--json' flag, it reads JSON formatted vector
$ valdcli -h vald.vdaas.org -p 8081 insert --json abc "[0.1, 0.2, 0.3, 0.4, 0.5, 0.6]"

search, search-by-id

$ valdcli search '[0.1 0.2 0.3 0.4 0.5 0.6]'

## using options
$ valdcli search --num 100 --epsilon 0.02 '[0.1 0.2 0.3 0.4 0.5 0.6]'

## search id 'xyz'
$ valdcli search-by-id --num 100 xyz

stream-insert, stream-search

$ valdcli stream-insert '[{:id "abc" :vector [0.1 0.2 0.3 0.4 0.5 0.6]} {:id "def" :vector [0.1 0.2 0.3 0.4 0.5 0.6]}]'

$ valdcli stream-search -n 5 '[[0.1 0.2 0.3 0.4 0.5 0.6] [0.1 0.2 0.3 0.4 0.5 0.6] [0.1 0.2 0.3 0.4 0.5 0.6]]'

$ valdcli stream-search-by-id -n 5 '["abc" "def" "xyz"]'

tips

usages of each commands available by running:

$ valdcli exists --help

License

Copyright (C) 2020 Vdaas.org Vald team

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FOSSA Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.