Skip to main content

A python client for the Koko Keywords API. The client handles caching to ensure very low latency.

Project description

Koko Keyword Python Client

A python client for the Koko Keywords API. The client handles caching to ensure very low latency.

Install

pip install koko_keywords

Usage

Set the KOKO_KEYWORDS_AUTH environment to the authentication string provided by Koko. To get an api key, complete our sign up form.

export KOKO_KEYWORDS_AUTH=username:password

Import the library

import koko_keywords

Then use the match function to check whether a query prompt matches a risky keyword

koko_keywords.match("sewerslide")

There is one optional param, filter.

Filter

Filter the keyword based on the taxonomy using a colon delimited list of “dimension=value” filters. Omitting a dimension does not filter by that dimension e.g.

koko_keywords.match("sewerslide", "category=eating,parenting:confidence=1,2")

This matches "sewerslide" against eating eating and parenting, with a confidence of 1 and 2 and any intensity (as intensity was omitted).

Performance

The underlying library is written in Rust and cross-compiled to the four major CPU targets. Regexes are cached based on the cache expiration headers (currently set to an hour). This ensures very low latency and overhead (< 1μs/req).

Error Handling

A RuntimeError will be raised with hints on how to resolve the issue. No exception handling should be necessary.

Logging

Minimal log messages are logged to STDERR

License

WWWWWW||WWWWWW
 W W W||W W W
      ||
    ( OO )__________
     /  |           \
    /o o|    MIT     \
    \___/||_||__||_|| *
         || ||  || ||
        _||_|| _||_||
       (__|__|(__|__|

(The MIT License)

Copyright (c) 2017 Koko AI Inc. us@kokocares.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

koko_keywords-0.3.2.tar.gz (8.2 MB view details)

Uploaded Source

Built Distribution

koko_keywords-0.3.2-py3-none-any.whl (8.2 MB view details)

Uploaded Python 3

File details

Details for the file koko_keywords-0.3.2.tar.gz.

File metadata

  • Download URL: koko_keywords-0.3.2.tar.gz
  • Upload date:
  • Size: 8.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for koko_keywords-0.3.2.tar.gz
Algorithm Hash digest
SHA256 87ca2f962f3e0ac51ce551582d29dee6906fd67f67f330dfe6e1d35d4d90c54d
MD5 1d1d3570720721499daf1d6fae3ab0cb
BLAKE2b-256 5da8d7e27e5ff8ec50c2502b6818037cf4f6ffa4d7f3c77e1d62ab80e39df65f

See more details on using hashes here.

File details

Details for the file koko_keywords-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: koko_keywords-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for koko_keywords-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af8aa27f898ccdb67f35a9249478f19c7bc5bbd40f2a398493b86cdcdd0bec11
MD5 8681f727197527d25e11483fae062d52
BLAKE2b-256 0b3c6a5fc9fbdc3bf097a4bdde1e21bea1cd9e9eefd009b6916e4f4878e91c79

See more details on using hashes here.

Supported by

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