### client connect to localhostfrom pyepsilla import vectordbdb = vectordb.Client()### client connect to remote serverfrom pyepsilla import vectordbdb = vectordb.Client( protocol='http', # http or https. Default is http host='3.100.100.100', # The host machine for the vector db. Default localhost port='8888'# The port for the vector db, default 8888)
// client connect to localhostconstepsillajs=require('epsillajs');constdb=newepsillajs.EpsillaDB();// client connect to remote serverconstepsillajs=require('epsillajs');constdb=newepsillajs.EpsillaDB({ protocol:'http',// http or https. Default is http host:'3.100.100.100',// The host machine for the vector db. Default localhost port:'8888'// The port for the vector db, default 8888});
In order to use OpenAI for embedding, pass in X-OpenAI-API-Key header:
db = vectordb.Client( ... headers={"X-OpenAI-API-Key": <Your OpenAI API key here> })
Use the command to load a database into memory. Epsilla can hold multiple databases in memory at the same time.
status_code, response = db.load_db( db_name="myDB", # The name of the DB. Can give any valid# name when loading a DB from disk. db_path="/tmp/epsilla", # The path on the disk where the DB is persisted. # If the path doesn't exist, will create# a new DB at this path. vector_scale=1000000, # (Optional) the limit of the number of records in# the table. Can provide any positive number at# load_db time. If not specified, the default value# is 150000. wal_enabled=True# (Optional) Enable write ahead log or not. Default # is True. For high throughput low consistency case,# can disable it to save disk IO.)
constload=awaitdb.loadDB("/tmp/epsilla",// The path on the disk where the DB is persisted. // If the path doesn't exist, will create// a new DB at this path."MyDB",// The name of the DB. Can give any valid// name when loading a DB from disk.1000000,// (Optional) the limit of the number of records in// the table. Can provide any positive number at// loadDB time. If not specified, the default value// is 150000.true// (Optional) Enable write ahead log or not. Default // is True. For high throughput low consistency case,// can disable it to save disk IO.);
Step 3. Use database
You can use the command to switch between multiple databases that are already loaded in memory. Then the following interactions will be towards this database.
db.use_db(db_name="myDB")
db.useDB("MyDB");
Connect to a vector database on Epsilla Cloud
First, create a vector database on Cloud GUI.
We will support creating vector databases via Python/JavaScript client in the near future.
Then connect to the created database. Replace the Project ID, Database ID and API Key.
from pyepsilla import cloudclient = cloud.Client( project_id="PROJECT-ID", # Copied from the GUI code snippet api_key="YOUR-API-KEY"# Replace with your API Key)db = client.vectordb(db_id="DB-ID")# Copied from the GUI code snippet
constepsillajs=require('epsillajs');constclient=newepsillajs.EpsillaCloud({ projectID:'PROJECT-ID',// Copied from the GUI code snippet apiKey:'YOUR-API-KEY'// Replace with your API Key});constdb=newepsillajs.VectorDB('DB-ID',// Copied from the GUI code snippet client ); awaitdb.connect();
The Project ID and Database ID can be copied from the database card under project resources:
The API Key can be created under project configurations: