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.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)
  • 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.1.tar.gz (3.7 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.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cpms_client-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 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.1.tar.gz
Algorithm Hash digest
SHA256 3c7f7d6fa4a050230ab01bd5c66c22c6c09017f04a267c391970be5f92b50a3d
MD5 59be4581bd8e78fe1adabe8e45bee7e1
BLAKE2b-256 6411cb96e1cdcdd3acab375abd19b5c160b2c0135f3ed6a2c31afd4c1a28b0bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cpms_client-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 742eea5578730a005265e7034652b455e5f02bc076c14d9957933f127f54660c
MD5 2e2edcd8053d25e164c9e1802eb43e44
BLAKE2b-256 5b08a01b143e14b4e18d7e0b41e5d7a138122c7cde5934737de5ed1e0c9192f4

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