Skip to main content

BagelDB is a Python library for interacting with the BagelDB API.

Project description

Sure, here's a step-by-step guide on how to use the BagelDB Python client:

  1. Import the BagelDB client

    Start by importing the BagelDB client into your Python script.

    from BagelDB import BagelDB
    
  2. Initialize the BagelDB client

    Next, initialize a new instance of the BagelDB client. Make sure you have your OpenAI API key set in your environment variables as OPENAI_API_KEY.

    db = BagelDB()
    
  3. Ping the BagelDB server

    To check the connection to the BagelDB server, you can use the ping() method. This method will return a response from the BagelDB API in JSON format.

    response = db.ping()
    print(response)
    
  4. Get OpenAI embeddings

    Use the getOpenAIEmbedding(inputText, model='text-embedding-ada-002') method to get embeddings from OpenAI. The inputText is the text for which embeddings are required. model is optional and defaults to 'text-embedding-ada-002'.

    input_text = "Some text"
    embeddings = db.getOpenAIEmbedding(input_text)
    print(embeddings)
    
  5. Insert vectors into BagelDB

    To insert vectors into a given index in BagelDB, use the insert(index, vectors) method. index is the index in which vectors are to be inserted, and vectors is a list of vectors to be inserted.

    index = "myIndex"
    vectors = [{'id': 'vec1', 'values': [0.1, 0.2, 0.3], 'metadata': {'key': 'value'}}]
    insert_response = db.insert(index, vectors)
    print(insert_response)
    
  6. Search for a vector in BagelDB

    To search for a vector in a given index in BagelDB, use the search(index, vector) method. index is the index in which the search is to be performed, and vector is the vector for which the search is to be performed.

    index = "myIndex"
    vector = [0.1, 0.2, 0.3]
    search_response = db.search(index, vector)
    print(search_response)
    

Remember to handle exceptions in your application. The methods in the BagelDB client can raise exceptions if a network error occurs or if the response from the server indicates a failed HTTP status code.

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

bageldb-beta-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

bageldb_beta-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file bageldb-beta-0.1.0.tar.gz.

File metadata

  • Download URL: bageldb-beta-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for bageldb-beta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 94b04e8f2ff28ab6afe24033deff1a6e645197d8848f352866e9bfc03b604216
MD5 bdc5edc04a1b40bf059236392cf7016e
BLAKE2b-256 df83a99a8bf141223d5b1215c11bcf81255596a154f7306c1958ae957d4288bd

See more details on using hashes here.

File details

Details for the file bageldb_beta-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bageldb_beta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for bageldb_beta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c86c6adf8c6d3787ccb383ee81ecb6596bcf31226ef2171e6edea9b2bceb72e
MD5 b8bf52d75ddad9df50a9bee0c8101600
BLAKE2b-256 9ca4372eb246b3e8a2b95472a9462e6ec96a9613600d83aeef0165377a4bb981

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