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.3.tar.gz (8.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: koko_keywords-0.3.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d6856ac6d104a6df19ea7ffc3be50bb714a72032084054361f27b208bfd8225e
MD5 58dc6609c702d143ae31757dec1e39e1
BLAKE2b-256 1258636eba6cb845204ea0066e5b5c4cbe422d160a5ab93e238ce3ca5dc9e9a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: koko_keywords-0.3.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a11123400d8ec74e192c89e4efd8d27397017cf4d5de9d8e3d4421d4a1c11411
MD5 540f9b4c8db08fdfe346331cdb4afcab
BLAKE2b-256 a3f6b2307bb4f9705108fa6573a0d047bb6d9d425f1e0fab05940bb843e9ef05

See more details on using hashes here.

Supported by

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