Epsilla Ruby SDK
Welcome to Ruby SDK for Epsilla Vector Database!
https://rubygems.org/gems/epsilla-ruby
Installation
bundle add epsilla-ruby
gem install epsilla-ruby
Usage
Run Epsilla Vectordb using Docker
docker run --pull=always -d -p 8888:8888 epsilla/vectordb
Use epsilla-ruby to connect to and interact with vector database
require "epsilla"
client = Epsilla::Client.new(protocol="http", host="127.0.0.1", port="8888")
status_code, response = client.database.load_db(db_name="MyDB", db_path="/tmp/epsilla")
puts status_code, response
client.database.use_db(db_name="MyDB")
table_fields= [
{"name" => "ID", "dataType" => "INT"},
{"name" => "Doc", "dataType" => "STRING"},
{"name" => "Embedding", "dataType" => "VECTOR_FLOAT", "dimensions" => 4}
]
status_code, response = client.database.create_table(table_name="MyTable", table_fields=table_fields)
puts status_code, response
table_records = [
{"ID" => 1, "Doc" => "Berlin", "Embedding" => [0.05, 0.61, 0.76, 0.74]},
{"ID" => 2, "Doc" => "London", "Embedding" => [0.19, 0.81, 0.75, 0.11]},
{"ID" => 3, "Doc" => "Moscow", "Embedding" => [0.36, 0.55, 0.47, 0.94]},
{"ID" => 4, "Doc" => "San Francisco", "Embedding" => [0.18, 0.01, 0.85, 0.80]},
{"ID" => 5, "Doc" => "Shanghai", "Embedding" => [0.24, 0.18, 0.22, 0.44]}
]
status_code, response = client.database.insert(table_name="MyTable", table_records=table_records)
puts status_code, response
status_code, response = client.database.rebuild()
puts status_code, response
query_field = "Embedding"
response_fields = ["Doc"]
query_vector=[0.35, 0.55, 0.47, 0.94]
limit=1
status_code, response = client.database.query(table_name="MyTable", query_field=query_field, query_vector=query_vector, response_fields=response_fields, limit=limit, with_distance=true)
puts status_code, response
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/epsilla-cloud/epsilla-ruby-client
If you have any question or problem, please join our discord https://discord.com/invite/cDaY2CxZc5