locusdb


Namelocusdb JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/the-alex-b/Locus
SummaryLocal, in-memory vector database
upload_time2023-04-29 14:38:34
maintainer
docs_urlNone
authorAlex
requires_python>=3.9,<4.0
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Locus
Locus is a local, simple, append-only, in-memory vector database based on hnswlib.

## Installation
``` bash
pip install locusdb
```
## Example Code
Some example code to illustrate Locus' functionality.

``` python
import numpy as np
from locusdb import Config, Vector, Index

# create a new configuration
config = Config(max_elements=1000, ef_construction=200, M=16, dim=128, space="cosine", storage_location="index.db")

# create a new index instance
index = Index(dimensions=config.dim, config=config)

# create some random vectors
vectors = []
for i in range(10):
    embedding = np.random.randn(config.dim)
    data = {"id": i, "message": f"test message {i}"}
    vector = Vector(embedding=embedding, data=data)
    vectors.append(vector)

# add the vectors to the index
for vector in vectors:
    index.add_vector(vector)

# retrieve the closest vectors to a query embedding
query_embedding = np.random.randn(config.dim)
results = index.retrieve(query_embedding, number_of_results=3)

print(f"Matches: {results}")
print(f"Items in index: {index.count}")

# store the index on disk
index._store_on_disk()

# load the index from disk
new_index = Index.from_file(config.storage_location)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/the-alex-b/Locus",
    "name": "locusdb",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Alex",
    "author_email": "46456279+the-alex-b@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/a2/be03cf4263a95fad8d90dc343732fc517c00913dee940c623e62cc2fb446/locusdb-0.3.0.tar.gz",
    "platform": null,
    "description": "# Locus\nLocus is a local, simple, append-only, in-memory vector database based on hnswlib.\n\n## Installation\n``` bash\npip install locusdb\n```\n## Example Code\nSome example code to illustrate Locus' functionality.\n\n``` python\nimport numpy as np\nfrom locusdb import Config, Vector, Index\n\n# create a new configuration\nconfig = Config(max_elements=1000, ef_construction=200, M=16, dim=128, space=\"cosine\", storage_location=\"index.db\")\n\n# create a new index instance\nindex = Index(dimensions=config.dim, config=config)\n\n# create some random vectors\nvectors = []\nfor i in range(10):\n    embedding = np.random.randn(config.dim)\n    data = {\"id\": i, \"message\": f\"test message {i}\"}\n    vector = Vector(embedding=embedding, data=data)\n    vectors.append(vector)\n\n# add the vectors to the index\nfor vector in vectors:\n    index.add_vector(vector)\n\n# retrieve the closest vectors to a query embedding\nquery_embedding = np.random.randn(config.dim)\nresults = index.retrieve(query_embedding, number_of_results=3)\n\nprint(f\"Matches: {results}\")\nprint(f\"Items in index: {index.count}\")\n\n# store the index on disk\nindex._store_on_disk()\n\n# load the index from disk\nnew_index = Index.from_file(config.storage_location)\n```\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Local, in-memory vector database",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/the-alex-b/Locus",
        "Repository": "https://github.com/the-alex-b/Locus"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3468cf5e459da454d173d93818e501e0800122331a7a14f221dfd000ed1b3619",
                "md5": "50322e1d47c095dd26dc410586ca3630",
                "sha256": "cc6392ae8f4c165765a46c3eedb600f28438e96c754d93a6ed93693eb575afbc"
            },
            "downloads": -1,
            "filename": "locusdb-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "50322e1d47c095dd26dc410586ca3630",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 8203,
            "upload_time": "2023-04-29T14:38:33",
            "upload_time_iso_8601": "2023-04-29T14:38:33.168769Z",
            "url": "https://files.pythonhosted.org/packages/34/68/cf5e459da454d173d93818e501e0800122331a7a14f221dfd000ed1b3619/locusdb-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3a2be03cf4263a95fad8d90dc343732fc517c00913dee940c623e62cc2fb446",
                "md5": "598d4178d00f67f0dd0cfef2ac82489c",
                "sha256": "a6dd1aa70c17d7c446b22738a385573afe9078753839fd8ccfcb9760e81f2ea3"
            },
            "downloads": -1,
            "filename": "locusdb-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "598d4178d00f67f0dd0cfef2ac82489c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 7470,
            "upload_time": "2023-04-29T14:38:34",
            "upload_time_iso_8601": "2023-04-29T14:38:34.853388Z",
            "url": "https://files.pythonhosted.org/packages/e3/a2/be03cf4263a95fad8d90dc343732fc517c00913dee940c623e62cc2fb446/locusdb-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-29 14:38:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "the-alex-b",
    "github_project": "Locus",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "locusdb"
}
        
Elapsed time: 0.08316s