venra


Namevenra JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/codycollier/venra
SummaryVenra provides a simple, high-level api for vespa.ai.
upload_time2023-08-26 15:16:15
maintainer
docs_urlNone
authorCody Collier
requires_python>=3.8, <4
licenseMIT
keywords artificial intelligence information retrieval machine learning search
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## venra

[![Project Status: WIP](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
![Tests](https://github.com/codycollier/venra/workflows/Tests/badge.svg)
![Release](https://github.com/codycollier/venra/workflows/Python%20Package%20Release/badge.svg)
[![PyPI version](https://badge.fury.io/py/venra.svg)](https://badge.fury.io/py/venra)


Venra provides a simple, high-level api for [vespa.ai](https://vespa.ai).

Venra targets subsets of Vespa's query, document, and system apis. It aims to 
encapsulate the complexity of dealing with the Vespa http interfaces, response
behaviors, and json responses for common client tasks.

Venra is well suited for web backends, command line tools, and enrichment
programs which need to retrieve, process, and update documents.


```python
import venra

qdata = {}
qdata["yql"] = "select * from sources awesome_docs;"
response = venra.query.search(qdata)

docs = venra.query.extract_docs(response)
for r, doc in enumerate(docs):
    print(f"rank: {r} >> {doc.some_id} title: {doc.title}")
```

Note: This library is under active development and the api is currently unstable.



### Installation

```bash
$ pip install venra
```


### Usage


Basic Query:

```python

import venra

# Build query
qdata = {}
qdata["yql"] = "select * from sources baz;"

# Run query
response = venra.query.search(qdata)

# Extract results via helpers
metrics = venra.query.extract_metrics(response)
docs = venra.query.extract_docs(response)

```


User Query and Grouping:
```python

from pprint import pprint

from venra import config as vconfig
from venra import query as vquery


# Configure
user_query = "machine learning"
vconfig.vespa_host_app = "http://localhost:8080"

# Build query including a grouping
qdata = {}
qdata["yql"] = "select post_id, post_date from sources baz where userQuery()"
qdata["yql"] += f" | all(group(time.date(post_date)) order(-max(post_date)) max(32) each(output(count())) as(day_counts) );"
qdata["hits"] = 10
qdata["timeout"] = "3300ms"
qdata["model.queryString"] = user_query
qdata["model.type"] = "weakAnd"
qdata["presentation.summary"] = "full"
qdata["presentation.timing"] = "true"

# Run query
response = vquery.search(qdata)

# Extract results via helpers
metrics = vquery.extract_metrics(response)
groups = vquery.extract_groups(response)
myfacet = vquery.extract_group_pairs(groups, "day_counts", "count()")
docs = vquery.extract_docs(response)

# Query results ready for use in app
pprint(metrics)
pprint(myfacet)
pprint(docs)
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/codycollier/venra",
    "name": "venra",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8, <4",
    "maintainer_email": "",
    "keywords": "artificial intelligence,information retrieval,machine learning,search",
    "author": "Cody Collier",
    "author_email": "cody@telnet.org",
    "download_url": "https://files.pythonhosted.org/packages/e6/b2/c12618e06a2814d7eadb68aead1963614fa2461d96a6aaa5b971a6629d56/venra-0.1.5.tar.gz",
    "platform": null,
    "description": "## venra\n\n[![Project Status: WIP](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)\n![Tests](https://github.com/codycollier/venra/workflows/Tests/badge.svg)\n![Release](https://github.com/codycollier/venra/workflows/Python%20Package%20Release/badge.svg)\n[![PyPI version](https://badge.fury.io/py/venra.svg)](https://badge.fury.io/py/venra)\n\n\nVenra provides a simple, high-level api for [vespa.ai](https://vespa.ai).\n\nVenra targets subsets of Vespa's query, document, and system apis. It aims to \nencapsulate the complexity of dealing with the Vespa http interfaces, response\nbehaviors, and json responses for common client tasks.\n\nVenra is well suited for web backends, command line tools, and enrichment\nprograms which need to retrieve, process, and update documents.\n\n\n```python\nimport venra\n\nqdata = {}\nqdata[\"yql\"] = \"select * from sources awesome_docs;\"\nresponse = venra.query.search(qdata)\n\ndocs = venra.query.extract_docs(response)\nfor r, doc in enumerate(docs):\n    print(f\"rank: {r} >> {doc.some_id} title: {doc.title}\")\n```\n\nNote: This library is under active development and the api is currently unstable.\n\n\n\n### Installation\n\n```bash\n$ pip install venra\n```\n\n\n### Usage\n\n\nBasic Query:\n\n```python\n\nimport venra\n\n# Build query\nqdata = {}\nqdata[\"yql\"] = \"select * from sources baz;\"\n\n# Run query\nresponse = venra.query.search(qdata)\n\n# Extract results via helpers\nmetrics = venra.query.extract_metrics(response)\ndocs = venra.query.extract_docs(response)\n\n```\n\n\nUser Query and Grouping:\n```python\n\nfrom pprint import pprint\n\nfrom venra import config as vconfig\nfrom venra import query as vquery\n\n\n# Configure\nuser_query = \"machine learning\"\nvconfig.vespa_host_app = \"http://localhost:8080\"\n\n# Build query including a grouping\nqdata = {}\nqdata[\"yql\"] = \"select post_id, post_date from sources baz where userQuery()\"\nqdata[\"yql\"] += f\" | all(group(time.date(post_date)) order(-max(post_date)) max(32) each(output(count())) as(day_counts) );\"\nqdata[\"hits\"] = 10\nqdata[\"timeout\"] = \"3300ms\"\nqdata[\"model.queryString\"] = user_query\nqdata[\"model.type\"] = \"weakAnd\"\nqdata[\"presentation.summary\"] = \"full\"\nqdata[\"presentation.timing\"] = \"true\"\n\n# Run query\nresponse = vquery.search(qdata)\n\n# Extract results via helpers\nmetrics = vquery.extract_metrics(response)\ngroups = vquery.extract_groups(response)\nmyfacet = vquery.extract_group_pairs(groups, \"day_counts\", \"count()\")\ndocs = vquery.extract_docs(response)\n\n# Query results ready for use in app\npprint(metrics)\npprint(myfacet)\npprint(docs)\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Venra provides a simple, high-level api for vespa.ai.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/codycollier/venra"
    },
    "split_keywords": [
        "artificial intelligence",
        "information retrieval",
        "machine learning",
        "search"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cceb8cf4154f6488941c44e971dfbf244bae3c915bce45d5a8c1688123533439",
                "md5": "87ef2de8e31d45edc3db0fde4bf6f322",
                "sha256": "fdc7f17d81f4ac9768c9adc88da6d6c337078dbadd931c8e75b8964590941643"
            },
            "downloads": -1,
            "filename": "venra-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "87ef2de8e31d45edc3db0fde4bf6f322",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8, <4",
            "size": 10918,
            "upload_time": "2023-08-26T15:16:14",
            "upload_time_iso_8601": "2023-08-26T15:16:14.467121Z",
            "url": "https://files.pythonhosted.org/packages/cc/eb/8cf4154f6488941c44e971dfbf244bae3c915bce45d5a8c1688123533439/venra-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6b2c12618e06a2814d7eadb68aead1963614fa2461d96a6aaa5b971a6629d56",
                "md5": "daa4dd18070e791f116e136954933650",
                "sha256": "f01c41c640da4c0982aea917f414908f8900cb5edd0f046f614ee2b934afec32"
            },
            "downloads": -1,
            "filename": "venra-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "daa4dd18070e791f116e136954933650",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8, <4",
            "size": 9501,
            "upload_time": "2023-08-26T15:16:15",
            "upload_time_iso_8601": "2023-08-26T15:16:15.624486Z",
            "url": "https://files.pythonhosted.org/packages/e6/b2/c12618e06a2814d7eadb68aead1963614fa2461d96a6aaa5b971a6629d56/venra-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-26 15:16:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "codycollier",
    "github_project": "venra",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "venra"
}
        
Elapsed time: 0.12687s