Skip to main content

An easy-to-use vector database.

Project description

Bhakti

<style> pre { white-space: pre; font-weight: 600; width: auto; height: auto; text-align: left; color: rgb(255, 255, 30); } .container { display: flex; flex-direction: column; justify-content: center; align-items: center; } </style>

Implemented with Numpy

                _oo0oo_ 
               o8888888o 
               88" . "88 
               (|     |) 
               0\  =  /0 
             ___/‘---’\___ 
           .' \|       |/ '. 
          / \\|||  :  |||// \  
         / _||||-BHAKTI-||||_ \ 
        |   | \\\  -  /// |   | 
        | \_|  ''\---/''  |_/ | 
        \  .-\__  '-'  ___/-. / 
      ___'. .'  /--.--\  '. .'___ 
  . ‘<  ‘.___\_<|>_/___.’>’ .     >’ 
 | | :  ‘- \‘.;‘\ _ /’;.’/ - ’ : | | |
  \  \ ‘_.   \_ __\ /__ _/   .-’ /  / 
  =‘-.____‘.___ \_____/___.-’___.-’= 

Bhakti is

  1. A light-weight vector database

  2. Easy to use

  3. Thread safe

  4. Portable

  5. Reliable

  6. Based only on Numpy

  7. Suitable for small-sized datasets

Installation

  • From PYPI

    pip install bhakti
    
  • From Github

    Download .whl first then run

    pip install ./bhakti-X.X.X-py3-none-any.whl
    

Quick Start

Before all, make sure you've successfully installed Bhakti :)

  • Run Bhakti Server

    • To begin, create a path for storing data

      mkdir -p /path/to/db
      
    • Start server using shell command

      1. Create configuration file (.yaml)

        # bhakti.yaml
        DIMENSION: 1024
        DB_PATH: /path/to/db
        DB_ENGINE: dipamkara # optional, default to dipamkara
        CACHED: false # optional, default to false
        HOST: 0.0.0.0 # optional, default to 0.0.0.0
        PORT: 23860 # optional, default to 23860
        EOF: <eof> # optional, default to <eof>
        TIMEOUT: 4.0 # optional, default to 4.0 seconds
        BUFFER_SIZE: 256 # optional, default to 256 bytes
        VERBOSE: false # optional, default to false
        
      2. Run bhakti in shell

        # bash
        bhakti ./bhakti.yaml
        
    • Start server using Python

      # main.py
      from bhakti import BhaktiServer
      from bhakti.database import DBEngine
      
      if __name__ == '__main__':
          bhakti_server = BhaktiServer(
              dimension=1024,  # required, only vectors with 1024 dimensions are acceptable
              db_path='/path/to/db',  # required, path where stores data, portable
              db_engine=DBEngine.DIPAMKARA,  # optional, default to dipamkara
              cached=False,  # optional, default to false
              host='0.0.0.0',  # optional, default to 0.0.0.0
              port=23860,  # optional, default to 23860
              eof=b'<eof>',  # optional, default to b'<eof>'
              timeout=4.0,  # optional, default to 4.0 seconds
              buffer_size=256,  # optional, default to 256 bytes
              verbose=False  # optional, default to false
          )
          # run server
          bhakti_server.run()
      
  • Interact With A Bhakti Client

    Currently, Python(>=3.10) is supported

    # main.py
    import asyncio
    import numpy as np
    from bhakti import BhaktiClient
    from bhakti.database import Metric
    from bhakti.database import DBEngine
    
    
    async def main():
        client = BhaktiClient(
            server='127.0.0.1',  # optional, default to 127.0.0.1
            port=23860,  # optional, default to 23860
            eof=b'<eof>',  # optional, default to b'<eof>'
            timeout=4.0,  # optional, default to 4.0 seconds
            buffer_size=256,  # optional, default to 256 bytes
            db_engine=DBEngine.DIPAMKARA,  # optional, default to dipamkara
            verbose=False  # optional, default to false
        )
        vector = np.random.randn(1024)
        await client.create(vector=vector, document={'age': 31, 'gender': 'male'})
        await client.create_index('age')
        await client.create_index('gender')
        results = await client.find_documents_by_vector_indexed(
            query='age <= 31 && gender != "female"', 
            vector=vector,
            metric=Metric.EUCLIDEAN_Z_SCORE, 
            top_k=3
        )
        print(results)
        
    
    if __name__ == '__main__':
        asyncio.run(main())
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bhakti-0.2.15.tar.gz (63.1 kB view details)

Uploaded Source

Built Distribution

bhakti-0.2.15-py3-none-any.whl (61.0 kB view details)

Uploaded Python 3

File details

Details for the file bhakti-0.2.15.tar.gz.

File metadata

  • Download URL: bhakti-0.2.15.tar.gz
  • Upload date:
  • Size: 63.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for bhakti-0.2.15.tar.gz
Algorithm Hash digest
SHA256 ba7b07905e213c67af43a7c7852809297fbf7b8f8cb686e5cce884c03df4bf49
MD5 2590fa33f0397145fda2dac8b3868fcd
BLAKE2b-256 3c3dfdade8d3833574c566eb945d9c0f51f799f8ed71f5684b264abd00d4df0c

See more details on using hashes here.

File details

Details for the file bhakti-0.2.15-py3-none-any.whl.

File metadata

  • Download URL: bhakti-0.2.15-py3-none-any.whl
  • Upload date:
  • Size: 61.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for bhakti-0.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 2c670eac59c5976b7740e7e78a50f298a5e5f768a82fedd5dbb66f1e7d702470
MD5 845470e79d7032892e66f0e4ee536f5b
BLAKE2b-256 a47b9cb99eb52106a4a66017b158402bd328ccef7021d290fdacba0a05c398f7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page