turbopuffer


Nameturbopuffer JSON
Version 0.1.15 PyPI version JSON
download
home_pagehttps://turbopuffer.com
SummaryPython Client for accessing the turbopuffer API
upload_time2024-06-07 17:03:27
maintainerNone
docs_urlNone
authorturbopuffer Inc.
requires_python<4.0,>=3.9
licenseMIT
keywords turbopuffer vector database cloud
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](https://github.com/turbopuffer/turbopuffer-python/assets/1594638/0482aa50-4665-4998-afd3-78afe56b52f3) turbopuffer Python Client [![CI Test](https://github.com/turbopuffer/turbopuffer-python/actions/workflows/ci_test.yml/badge.svg)](https://github.com/turbopuffer/turbopuffer-python/actions/workflows/ci_test.yml)
=========================

The official Python client for accessing the turbopuffer API.

Usage
-----

1. Install the turbopuffer package and set your API key.
```sh
$ pip install turbopuffer
```
Or if you're able to run C binaries for JSON encoding, use:
```sh
$ pip install turbopuffer[fast]
```

2. Start using the API
```py
import turbopuffer as tpuf
tpuf.api_key = 'your-token'  # Alternatively: export=TURBOPUFFER_API_KEY=your-token

# Open a namespace
ns = tpuf.Namespace('hello_world')

# Read namespace metadata
if ns.exists():
    print(f'Namespace {ns.name} exists with {ns.dimensions()} dimensions and approximately {ns.approx_count()} vectors.')

# Upsert your dataset
ns.upsert(
    ids=[1, 2],
    vectors=[[0.1, 0.2], [0.3, 0.4]],
    attributes={'name': ['foo', 'foos']},
    distance_metric='cosine_distance',
)

# Alternatively, upsert using a row iterator
ns.upsert(
    {
        'id': id,
        'vector': [id/10, id/10],
        'attributes': {'name': 'food', 'num': 8}
    } for id in range(3, 10),
    distance_metric='cosine_distance',
)

# Query your dataset
vectors = ns.query(
    vector=[0.15, 0.22],
    distance_metric='cosine_distance',
    top_k=10,
    filters=['And', [
        ['name', 'Glob', 'foo*'],
        ['name', 'NotEq', 'food'],
    ]],
    include_attributes=['name'],
    include_vectors=True
)
print(vectors)
# [
#   VectorRow(id=2, vector=[0.30000001192092896, 0.4000000059604645], attributes={'name': 'foos'}, dist=0.001016080379486084),
#   VectorRow(id=1, vector=[0.10000000149011612, 0.20000000298023224], attributes={'name': 'foo'}, dist=0.009067952632904053)
# ]

# List all namespaces
namespaces = tpuf.namespaces()
print('Total namespaces:', len(namespaces))
for namespace in namespaces:
    print('Namespace', namespace.name, 'contains approximately', namespace.approx_count(),
            'vectors with', namespace.dimensions(), 'dimensions.')

# Delete vectors using the separate delete method
ns.delete([1, 2])
```

Endpoint Documentation
----------------------

For more details on request parameters and query options, check the docs at https://turbopuffer.com/docs

            

Raw data

            {
    "_id": null,
    "home_page": "https://turbopuffer.com",
    "name": "turbopuffer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "turbopuffer, vector, database, cloud",
    "author": "turbopuffer Inc.",
    "author_email": "info@turbopuffer.com",
    "download_url": "https://files.pythonhosted.org/packages/ad/23/82bc824c575e651c717712c3ad232d18686bde82916c08f89615c1496a09/turbopuffer-0.1.15.tar.gz",
    "platform": null,
    "description": "![](https://github.com/turbopuffer/turbopuffer-python/assets/1594638/0482aa50-4665-4998-afd3-78afe56b52f3) turbopuffer Python Client [![CI Test](https://github.com/turbopuffer/turbopuffer-python/actions/workflows/ci_test.yml/badge.svg)](https://github.com/turbopuffer/turbopuffer-python/actions/workflows/ci_test.yml)\n=========================\n\nThe official Python client for accessing the turbopuffer API.\n\nUsage\n-----\n\n1. Install the turbopuffer package and set your API key.\n```sh\n$ pip install turbopuffer\n```\nOr if you're able to run C binaries for JSON encoding, use:\n```sh\n$ pip install turbopuffer[fast]\n```\n\n2. Start using the API\n```py\nimport turbopuffer as tpuf\ntpuf.api_key = 'your-token'  # Alternatively: export=TURBOPUFFER_API_KEY=your-token\n\n# Open a namespace\nns = tpuf.Namespace('hello_world')\n\n# Read namespace metadata\nif ns.exists():\n    print(f'Namespace {ns.name} exists with {ns.dimensions()} dimensions and approximately {ns.approx_count()} vectors.')\n\n# Upsert your dataset\nns.upsert(\n    ids=[1, 2],\n    vectors=[[0.1, 0.2], [0.3, 0.4]],\n    attributes={'name': ['foo', 'foos']},\n    distance_metric='cosine_distance',\n)\n\n# Alternatively, upsert using a row iterator\nns.upsert(\n    {\n        'id': id,\n        'vector': [id/10, id/10],\n        'attributes': {'name': 'food', 'num': 8}\n    } for id in range(3, 10),\n    distance_metric='cosine_distance',\n)\n\n# Query your dataset\nvectors = ns.query(\n    vector=[0.15, 0.22],\n    distance_metric='cosine_distance',\n    top_k=10,\n    filters=['And', [\n        ['name', 'Glob', 'foo*'],\n        ['name', 'NotEq', 'food'],\n    ]],\n    include_attributes=['name'],\n    include_vectors=True\n)\nprint(vectors)\n# [\n#   VectorRow(id=2, vector=[0.30000001192092896, 0.4000000059604645], attributes={'name': 'foos'}, dist=0.001016080379486084),\n#   VectorRow(id=1, vector=[0.10000000149011612, 0.20000000298023224], attributes={'name': 'foo'}, dist=0.009067952632904053)\n# ]\n\n# List all namespaces\nnamespaces = tpuf.namespaces()\nprint('Total namespaces:', len(namespaces))\nfor namespace in namespaces:\n    print('Namespace', namespace.name, 'contains approximately', namespace.approx_count(),\n            'vectors with', namespace.dimensions(), 'dimensions.')\n\n# Delete vectors using the separate delete method\nns.delete([1, 2])\n```\n\nEndpoint Documentation\n----------------------\n\nFor more details on request parameters and query options, check the docs at https://turbopuffer.com/docs\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Client for accessing the turbopuffer API",
    "version": "0.1.15",
    "project_urls": {
        "Documentation": "https://turbopuffer.com/docs",
        "Homepage": "https://turbopuffer.com",
        "Repository": "https://github.com/turbopuffer/turbopuffer-python"
    },
    "split_keywords": [
        "turbopuffer",
        " vector",
        " database",
        " cloud"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7899c06b0d38a05e45b16fd52a57709a61497a36712f1967474e54627047e774",
                "md5": "c1679b8185749dc406be31a54b98d661",
                "sha256": "0e20cca99df6e4682e2835a48830488b446f5c8548ded8efa8fe8ce9838fef67"
            },
            "downloads": -1,
            "filename": "turbopuffer-0.1.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c1679b8185749dc406be31a54b98d661",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 14950,
            "upload_time": "2024-06-07T17:03:26",
            "upload_time_iso_8601": "2024-06-07T17:03:26.413081Z",
            "url": "https://files.pythonhosted.org/packages/78/99/c06b0d38a05e45b16fd52a57709a61497a36712f1967474e54627047e774/turbopuffer-0.1.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad2382bc824c575e651c717712c3ad232d18686bde82916c08f89615c1496a09",
                "md5": "c0d979e87061beca771f2495b19e7c71",
                "sha256": "d3c5db4f7aba09ed6cbc84a7a49e76e580141f32c9dcbf99ff24a6ee262fde15"
            },
            "downloads": -1,
            "filename": "turbopuffer-0.1.15.tar.gz",
            "has_sig": false,
            "md5_digest": "c0d979e87061beca771f2495b19e7c71",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 13304,
            "upload_time": "2024-06-07T17:03:27",
            "upload_time_iso_8601": "2024-06-07T17:03:27.548390Z",
            "url": "https://files.pythonhosted.org/packages/ad/23/82bc824c575e651c717712c3ad232d18686bde82916c08f89615c1496a09/turbopuffer-0.1.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-07 17:03:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "turbopuffer",
    "github_project": "turbopuffer-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "turbopuffer"
}
        
Elapsed time: 0.26254s