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 from PyPI

pip install cpms-client

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.1-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)
  • detect_form(html, screenshot_path=None, screenshot=None, url=None, dom_snapshot=None, observation=None) - High-level form detection endpoint
  • 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 Distribution

cpms_client-0.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

cpms_client-0.1.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file cpms_client-0.1.2.tar.gz.

File metadata

  • Download URL: cpms_client-0.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cpms_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8b0d56e60fada470ea0ab50048f62583df57ce6e4d6f2bde47284d6f7166f206
MD5 07701b12c0b0c8307e2f5819c7aaba52
BLAKE2b-256 8cef6a7e6ec3131b99f2f28758b4d4a9ea4f8b6127177100897a7a693c54ded4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cpms_client-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55aff72355bd26aac3a33d4cbe9ae71d91ac9d456b3ad93cca54fdb149720b97
MD5 5b8733f42f1c0c0c74555b8bfa3f53fc
BLAKE2b-256 8580d9be8efac469231bc9197e0c795458e83665bd5dc65c0f60bfbac8244a7c

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