Skip to main content

Python wrapper for the CPMS HTTP API

Project description

cpms-client (Python)

Lightweight Python wrapper around the CPMS HTTP API exposed by @lehelkovach/cpms-server-node.

Install

This package uses setuptools (install python -m pip install build if you don't have build yet). Build/install locally from the repo root:

cd python/cpms_client
python -m build
pip install dist/cpms-client-0.1.0-py3-none-any.whl

Usage

from cpms_client import CpmsClient

client = CpmsClient(base_url="http://localhost:8787")

concept = {
    "concept_id": "concept:email@1.0.0",
    "signals": [
        {"signal_id": "terms", "evaluator": "dom.text_contains_any", "params": {"terms": ["email"]}, "mode": "fuzzy", "weight": 1.0}
    ],
    "resolution": {"score_model": {"type": "hybrid_logit", "prior_logit": -1.0, "calibration": "sigmoid"}}
}

observation = {"page_id": "fixture:login", "candidates": [{"candidate_id": "cand_email", "dom": {"label_text": "Email"}}]}

result = client.match(concept, observation)
print(result["result"]["best"])

API helpers

  • match(concept, observation)
  • match_explain(concept, observation)
  • match_pattern(pattern, concepts, observation)
  • schema_language()
  • concept_template(intent=None)
  • persist_concept(concept)
  • draft_concept(intent=None)
  • draft_pattern(intent=None)
  • activate(kind, uuid)

All methods raise RuntimeError when the HTTP call fails (non-2xx or network issues).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

cpms_client-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file cpms_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cpms_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cpms_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac0ea218381473fc02c62675cdabb92e256adc53e7604a69778cf0aff9d17a80
MD5 c90ddacc921616cac9680e1fbc381b5c
BLAKE2b-256 b79edbfa02680ea34d62964db6c68ca39b43167016205a1123ee6044e09ad884

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