Python SDK for the Aithericon HPI API — typed client for human-in-the-loop tasks
Project description
aithericon-hpi
Python SDK for the Aithericon HPI API — typed client for human-in-the-loop tasks.
Install
pip install aithericon-hpi
Quick Start
from hpi_client import HPIClient
client = HPIClient("https://app.hpi.dev", "htk_your-token")
# Create a task
task = client.create_task(
title="Review deployment plan",
steps=[{
"id": "review",
"title": "Review",
"blocks": [
{"type": "mdsvex", "content": "Please review the deployment plan for **v2.1**."},
{"type": "input", "field": {"name": "approved", "label": "Approve?", "kind": "checkbox"}},
],
}],
)
print(f"Task created: {task['task_id']}")
print(f"Magic link: {task['url']}")
# Wait for the human to complete it
result = client.wait_for_task(task["task_id"])
print(result["status"]) # "completed"
print(result["data"]) # {"approved": True}
API
Tasks
# Create
task = client.create_task(title="...", steps=[...])
task = client.create_task(
title="...",
steps=[...],
assignee_email="alice@example.com",
metadata={"env": "production"},
sinks=[{"type": "webhook", "url": "https://..."}],
)
# Read
task = client.get_task("task-id")
task = client.get_task("task-id", include_definition=True)
result = client.list_tasks(status="pending", sort="newest", limit=10)
# Lifecycle
client.complete_task("task-id", data={"approved": True})
client.cancel_task("task-id", reason="No longer needed")
client.notify_task("task-id")
# Wait (long-poll)
result = client.wait_for_task("task-id", timeout=300)
if result.get("timed_out"):
print("Still pending")
# Templates
templates = client.list_task_templates()
Task Links
link = client.create_task_link("task-id", assignee_email="bob@example.com")
links = client.list_task_links("task-id")
client.delete_task_link("task-id", "link-id")
Processes
proc = client.create_process(
namespace="deployments",
name="Deploy v2.1",
steps=[
{"key": "build", "label": "Build"},
{"key": "review", "label": "Human Review", "human": True},
{"key": "deploy", "label": "Deploy"},
],
)
client.update_process(proc["process_id"], {"type": "step_started", "step": "build"})
client.update_process(proc["process_id"], {"type": "step_completed", "step": "build"})
client.update_process(proc["process_id"], {"type": "completed"})
proc = client.get_process(proc["process_id"])
result = client.list_processes(status="running", namespace="deployments")
Process Links
link = client.create_process_link("process-id", assignee_email="alice@example.com")
links = client.list_process_links("process-id")
File Upload
with open("report.pdf", "rb") as f:
result = client.upload_file(f.read(), "report.pdf", "application/pdf")
print(result["url"])
Error Handling
from hpi_client.client import HPIError
try:
client.get_task("nonexistent")
except HPIError as e:
print(e.status) # 404
print(e.error) # "Task not found"
print(e.details) # None or list of validation details
Context Manager
with HPIClient("https://app.hpi.dev", "htk_your-token") as client:
task = client.create_task(title="...", steps=[...])
# connection closed automatically
Self-Hosted
client = HPIClient("https://hpi.yourcompany.com", "htk_your-token")
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aithericon_hpi-0.1.0.tar.gz
(10.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aithericon_hpi-0.1.0.tar.gz.
File metadata
- Download URL: aithericon_hpi-0.1.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.14.0 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79b1dbd5e3c348986f7454b7a1a299b8c677c2422e013236bbd489b25b9083ec
|
|
| MD5 |
f227736b3f6c4f7acd45f16adf638864
|
|
| BLAKE2b-256 |
eb153f5c836f5da4fda47d982cf26f8629ea732bdfa0af5734b617c456a5cb06
|
File details
Details for the file aithericon_hpi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aithericon_hpi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.14.0 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7e615c993e9de23b17625fcb3911524b77ccbf5496528f832d2a9de58a33459
|
|
| MD5 |
3a456cfa688b393e77ee92e12f9c4873
|
|
| BLAKE2b-256 |
fcd05d0a6075c4a27e93e8d18db84fee668329528c814347f2305d04a1b345d0
|