palqee-prisma-client 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- palqee_prisma_client-0.4.0/.coveragerc +19 -0
- palqee_prisma_client-0.4.0/.gitignore +69 -0
- palqee_prisma_client-0.4.0/CHANGELOG.md +91 -0
- palqee_prisma_client-0.4.0/PKG-INFO +194 -0
- palqee_prisma_client-0.4.0/README.md +176 -0
- palqee_prisma_client-0.4.0/pyproject.toml +44 -0
- palqee_prisma_client-0.4.0/pytest.ini +35 -0
- palqee_prisma_client-0.4.0/scripts/sdk_live_check.py +399 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/__init__.py +70 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/_auth.py +39 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/_http.py +316 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/client.py +98 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/config/__init__.py +34 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/config/evaluation.py +110 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/config/evaluators.py +674 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/config/mapping.py +47 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/exceptions.py +91 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/models.py +402 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/resources/__init__.py +15 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/resources/analytics.py +191 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/resources/evaluations.py +74 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/resources/projects.py +180 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/resources/runs.py +230 -0
- palqee_prisma_client-0.4.0/src/palqee_prisma_client/version.py +1 -0
- palqee_prisma_client-0.4.0/tests/__init__.py +0 -0
- palqee_prisma_client-0.4.0/tests/config/__init__.py +0 -0
- palqee_prisma_client-0.4.0/tests/config/test_evaluation.py +110 -0
- palqee_prisma_client-0.4.0/tests/config/test_evaluators.py +972 -0
- palqee_prisma_client-0.4.0/tests/conftest.py +62 -0
- palqee_prisma_client-0.4.0/tests/test_contract.py +319 -0
- palqee_prisma_client-0.4.0/tests/test_package.py +31 -0
- palqee_prisma_client-0.4.0/tests/unit/__init__.py +0 -0
- palqee_prisma_client-0.4.0/tests/unit/resources/__init__.py +0 -0
- palqee_prisma_client-0.4.0/tests/unit/resources/test_analytics.py +235 -0
- palqee_prisma_client-0.4.0/tests/unit/resources/test_evaluations.py +125 -0
- palqee_prisma_client-0.4.0/tests/unit/resources/test_projects.py +224 -0
- palqee_prisma_client-0.4.0/tests/unit/resources/test_runs.py +342 -0
- palqee_prisma_client-0.4.0/tests/unit/test_http.py +113 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[run]
|
|
2
|
+
source = src
|
|
3
|
+
branch = true
|
|
4
|
+
|
|
5
|
+
[report]
|
|
6
|
+
exclude_lines =
|
|
7
|
+
pragma: no cover
|
|
8
|
+
def __repr__
|
|
9
|
+
raise NotImplementedError
|
|
10
|
+
if __name__ == .__main__.:
|
|
11
|
+
^\s*pass\s*$
|
|
12
|
+
raise ImportError
|
|
13
|
+
@abstractmethod
|
|
14
|
+
|
|
15
|
+
[html]
|
|
16
|
+
directory = coverage_html
|
|
17
|
+
|
|
18
|
+
[xml]
|
|
19
|
+
output = coverage.xml
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# IDE - only ignore temporary/local files
|
|
2
|
+
.cursor/logs/
|
|
3
|
+
.cursor/cache/
|
|
4
|
+
.cursor/.local/
|
|
5
|
+
.vscode/.history/
|
|
6
|
+
.idea
|
|
7
|
+
|
|
8
|
+
# Python
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[cod]
|
|
11
|
+
*$py.class
|
|
12
|
+
*.so
|
|
13
|
+
.Python
|
|
14
|
+
build/
|
|
15
|
+
develop-eggs/
|
|
16
|
+
dist/
|
|
17
|
+
downloads/
|
|
18
|
+
eggs/
|
|
19
|
+
.eggs/
|
|
20
|
+
lib/
|
|
21
|
+
lib64/
|
|
22
|
+
parts/
|
|
23
|
+
sdist/
|
|
24
|
+
var/
|
|
25
|
+
wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
|
|
30
|
+
# Package manager lock files
|
|
31
|
+
packages/*/uv.lock
|
|
32
|
+
|
|
33
|
+
# Virtual Environment
|
|
34
|
+
.env
|
|
35
|
+
.venv
|
|
36
|
+
env/
|
|
37
|
+
venv/
|
|
38
|
+
ENV/
|
|
39
|
+
|
|
40
|
+
# Coverage
|
|
41
|
+
.coverage
|
|
42
|
+
coverage.xml
|
|
43
|
+
htmlcov/
|
|
44
|
+
|
|
45
|
+
# Worktrees
|
|
46
|
+
.worktrees/
|
|
47
|
+
|
|
48
|
+
# Patch files
|
|
49
|
+
*.patch
|
|
50
|
+
|
|
51
|
+
# Misc
|
|
52
|
+
.DS_Store
|
|
53
|
+
|
|
54
|
+
# Testing
|
|
55
|
+
.pytest_cache/
|
|
56
|
+
.mypy_cache/
|
|
57
|
+
|
|
58
|
+
# Distribution
|
|
59
|
+
*.tar.gz
|
|
60
|
+
*.zip
|
|
61
|
+
*.rar
|
|
62
|
+
*.7z
|
|
63
|
+
|
|
64
|
+
# Logs
|
|
65
|
+
*.log
|
|
66
|
+
logs/
|
|
67
|
+
|
|
68
|
+
.secrets
|
|
69
|
+
src/prisma_ai/tests/e2e/
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.4.0](https://github.com/Palqee/prisma-ai/compare/palqee-prisma-client-v0.3.1...palqee-prisma-client-v0.4.0) (2026-05-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* PyPI distribution names changed. Users must pip install palqee-prisma-client (was pq-prisma-client) and pip install palqee-prisma-otel (was pq-prisma-otel). Imports also change: from palqee_prisma_client import ... (was pq_prisma_client) and import palqee_prisma_otel (was prisma_otel).
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* rename subpackages to palqee-prisma-* namespace ([d7f9e07](https://github.com/Palqee/prisma-ai/commit/d7f9e072702fc671af68999fb08d5cbed77a3470))
|
|
13
|
+
|
|
14
|
+
## [0.3.1](https://github.com/Palqee/prisma-ai/compare/pq-prisma-client-v0.3.0...pq-prisma-client-v0.3.1) (2026-05-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **sdk:** PM-1948 fixed renaming ([b3bbb8f](https://github.com/Palqee/prisma-ai/commit/b3bbb8f5c9b363d36fbae8cef0856835d8fb32ab))
|
|
20
|
+
* **sdk:** PM-1948 renamed env variables ([770154f](https://github.com/Palqee/prisma-ai/commit/770154f4d9e2ebd9ac0db91944cd24c697f53f21))
|
|
21
|
+
* **sdk:** PM-1948 renamed variables ([ffb966e](https://github.com/Palqee/prisma-ai/commit/ffb966e8279609cfd36a8a97f2bd7062e0f42e5a))
|
|
22
|
+
|
|
23
|
+
## [0.3.0](https://github.com/Palqee/prisma-ai/compare/pq-prisma-client-v0.2.3...pq-prisma-client-v0.3.0) (2026-05-22)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### ⚠ BREAKING CHANGES
|
|
27
|
+
|
|
28
|
+
* PyPI distribution names changed. Users must run `pip install pq-prisma-ai` (was `prisma-ai`) and `pip install pq-prisma-otel` (was `prisma-otel`). Imports unchanged.
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* rename PyPI packages to pq-* namespace ([cf9e653](https://github.com/Palqee/prisma-ai/commit/cf9e653371f2d261dc34e984e06b9a9237327c76))
|
|
33
|
+
|
|
34
|
+
## [0.2.3](https://github.com/Palqee/prisma-ai/compare/pq-prisma-client-v0.2.2...pq-prisma-client-v0.2.3) (2026-05-07)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* **sdk:** PM-1149 aligned ai with backend ([55af7c7](https://github.com/Palqee/prisma-ai/commit/55af7c7085d77468ddffa37cdeb5e13b157ff9d8))
|
|
40
|
+
* **sdk:** PM-1149 finalized new methods ([57332db](https://github.com/Palqee/prisma-ai/commit/57332db0e602e107efc8325e7fef09f98cdd66a8))
|
|
41
|
+
* **sdk:** PM-1149 fixed ci-cd issues ([3ea8937](https://github.com/Palqee/prisma-ai/commit/3ea89379a93a375946c731c27913a90abc0874dd))
|
|
42
|
+
* **sdk:** PM-1149 fixed mypy ([2ea4c64](https://github.com/Palqee/prisma-ai/commit/2ea4c64e99b270a1486bf474a72a6680530558c1))
|
|
43
|
+
* **sdk:** PM-1149 fixed pr feedback ([cf4e6c8](https://github.com/Palqee/prisma-ai/commit/cf4e6c8d5f985270afd6ea38b610a74e182b151e))
|
|
44
|
+
* **sdk:** PM-1149 fixed ruff ([24f096c](https://github.com/Palqee/prisma-ai/commit/24f096c937e3a9a1ba87480e665a7a5e11c7731b))
|
|
45
|
+
* **sdk:** PM-1149 fixed ruff and tests ([1609bea](https://github.com/Palqee/prisma-ai/commit/1609beaad5e2c0671878aaffeaf5747030306d1b))
|
|
46
|
+
* **sdk:** PM-1149 new sdk methods ([774c93d](https://github.com/Palqee/prisma-ai/commit/774c93d8162deb0da43085e4228a45ec16819b86))
|
|
47
|
+
* **sdk:** PM-1149 new sdk methods ([5e3c2d9](https://github.com/Palqee/prisma-ai/commit/5e3c2d97f2c65cd97eaf4ace3bbb216703d7df75))
|
|
48
|
+
* **sdk:** PM-1149 PR review resolved ([78e23ba](https://github.com/Palqee/prisma-ai/commit/78e23bafc392c732954401bcbb9ea25155948202))
|
|
49
|
+
* **sdk:** PM-1343 Remove workspace_id from client (resolved server-side from API key) ([2296084](https://github.com/Palqee/prisma-ai/commit/2296084b780e14d4fa06ae5b7cda1968821cbdd1))
|
|
50
|
+
* **sdk:** PM-1343 Remove workspace_id from client (resolved server-side from API key) ([1eea0a0](https://github.com/Palqee/prisma-ai/commit/1eea0a09279d8430cc4c688903f7f106424d8beb))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
* **sdk:** PM-1149 fix mypy type errors in sdk_live_check ([c4113aa](https://github.com/Palqee/prisma-ai/commit/c4113aa9e6a801b01339eb68b59256db9187ecff))
|
|
56
|
+
|
|
57
|
+
## [0.2.2](https://github.com/Palqee/prisma-ai/compare/pq-prisma-client-v0.2.1...pq-prisma-client-v0.2.2) (2026-03-23)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Bug Fixes
|
|
61
|
+
|
|
62
|
+
* **prisma-client:** PM-831 split client/server exception hierarchy ([af9c20c](https://github.com/Palqee/prisma-ai/commit/af9c20cd65544b526f46b81a155f4d02461e4a73))
|
|
63
|
+
|
|
64
|
+
## [0.2.1](https://github.com/Palqee/prisma-ai/compare/pq-prisma-client-v0.2.0...pq-prisma-client-v0.2.1) (2026-03-19)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
* **pq-prisma-client:** add evaluation config classes ([e61c5c1](https://github.com/Palqee/prisma-ai/commit/e61c5c13adf3b47739696f32e26b819f6ef6ef12))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
* **pq-prisma-client:** import Self from typing_extensions for 3.10 ([9bcf968](https://github.com/Palqee/prisma-ai/commit/9bcf968aaa4dcec5abe293c567051924de1684a0))
|
|
75
|
+
* **pq-prisma-client:** PM-830 fix regex and validation bugs ([3a0e599](https://github.com/Palqee/prisma-ai/commit/3a0e599a0d3f810bb1d1ea354b27ced87a906ab4))
|
|
76
|
+
* **pq-prisma-client:** PM-833 json-mode dump and tags test ([d16751d](https://github.com/Palqee/prisma-ai/commit/d16751dca43c9dcf235108b2642b1b6353afaa7d))
|
|
77
|
+
* **pq-prisma-client:** predefined option validation parity ([d972a91](https://github.com/Palqee/prisma-ai/commit/d972a91936fd82c3a7cedddaadbfb0ca3eb6f6cf))
|
|
78
|
+
* **pq-prisma-client:** version test validates format not value ([b8c39c7](https://github.com/Palqee/prisma-ai/commit/b8c39c7167651b2d6b16baec8050122432726255))
|
|
79
|
+
|
|
80
|
+
## [0.2.0](https://github.com/Palqee/prisma-ai/compare/pq-prisma-client-v0.1.0...pq-prisma-client-v0.2.0) (2026-03-06)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
* **pq-prisma-client:** PM-618 scaffold pq-prisma-client package ([cbb928b](https://github.com/Palqee/prisma-ai/commit/cbb928b41c715af6d1d343dde31795a994608e9a))
|
|
86
|
+
* **pq-prisma-client:** PM-618 scaffold pq-prisma-client package ([5632ed2](https://github.com/Palqee/prisma-ai/commit/5632ed2bd027896aaa07d0719d1c96b7fae7a394))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### Bug Fixes
|
|
90
|
+
|
|
91
|
+
* **sdk:** PM-618 remove dead pytest config, anchor pass regex ([8d6ebe6](https://github.com/Palqee/prisma-ai/commit/8d6ebe6e06cdcde2e5334d201532b80ff7a25280))
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: palqee-prisma-client
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Prisma AI platform client for evaluations, datasets, and jobs
|
|
5
|
+
Author-email: Hartley Jean-Aime <hartley@palqee.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: httpx>=0.27
|
|
9
|
+
Requires-Dist: pydantic>=2.0
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
12
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
14
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
16
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# palqee-prisma-client
|
|
20
|
+
|
|
21
|
+
Python client for the Prisma AI platform. Provides async access to projects, runs, analytics, and evaluations through a typed API.
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
- Python 3.10 or later
|
|
26
|
+
- A Prisma AI API key
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install palqee-prisma-client
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from palqee_prisma_client import PrismaClient
|
|
38
|
+
|
|
39
|
+
async with PrismaClient(
|
|
40
|
+
api_key="pq_prisma_sk_...",
|
|
41
|
+
workspace_id="<workspace-uuid>",
|
|
42
|
+
base_url="https://your-prisma-host",
|
|
43
|
+
) as client:
|
|
44
|
+
# Create a project and a run
|
|
45
|
+
project = await client.projects.get_or_create("my-app")
|
|
46
|
+
run = await client.runs.create(project.id)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Projects
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
# List all projects in the workspace
|
|
53
|
+
page = await client.projects.list()
|
|
54
|
+
for project in page.items:
|
|
55
|
+
print(project.id, project.name)
|
|
56
|
+
|
|
57
|
+
# Get a single project
|
|
58
|
+
project = await client.projects.get(project_id)
|
|
59
|
+
|
|
60
|
+
# Update a project
|
|
61
|
+
project = await client.projects.update(project_id, name="new-name", description="...")
|
|
62
|
+
|
|
63
|
+
# Get aggregate stats
|
|
64
|
+
stats = await client.projects.stats(project_id)
|
|
65
|
+
print(stats.total_runs, stats.total_traces)
|
|
66
|
+
|
|
67
|
+
# Delete a project
|
|
68
|
+
await client.projects.delete(project_id)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Runs
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
# List runs in a project (with optional filters)
|
|
75
|
+
page = await client.runs.list(project_id, status="completed", limit=50)
|
|
76
|
+
for run in page.items:
|
|
77
|
+
print(run.id, run.status)
|
|
78
|
+
|
|
79
|
+
# Get a single run
|
|
80
|
+
run = await client.runs.get(run_id)
|
|
81
|
+
|
|
82
|
+
# Update a run
|
|
83
|
+
run = await client.runs.update(run_id, status="completed")
|
|
84
|
+
|
|
85
|
+
# Get stats and evaluation metrics
|
|
86
|
+
stats = await client.runs.stats(run_id)
|
|
87
|
+
metrics = await client.runs.metrics(run_id)
|
|
88
|
+
print(metrics.metrics) # {"correctness": 0.88, ...}
|
|
89
|
+
|
|
90
|
+
# Delete a run
|
|
91
|
+
await client.runs.delete(run_id)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Analytics
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
# Structured query
|
|
98
|
+
result = await client.analytics.query(
|
|
99
|
+
dimensions=["model_name"],
|
|
100
|
+
measures=["trace_count", "avg_latency_ms"],
|
|
101
|
+
filters=[{"field": "project_id", "op": "eq", "value": project_id}],
|
|
102
|
+
)
|
|
103
|
+
for row in result.rows:
|
|
104
|
+
print(row.dimensions, row.measures)
|
|
105
|
+
|
|
106
|
+
# Project overview
|
|
107
|
+
overview = await client.analytics.overview(project_id, period="7d")
|
|
108
|
+
print(overview.total_traces, overview.total_cost_usd)
|
|
109
|
+
|
|
110
|
+
# Cost breakdown
|
|
111
|
+
costs = await client.analytics.costs(project_id, period="30d")
|
|
112
|
+
for item in costs.breakdown:
|
|
113
|
+
print(item.label, item.cost_usd)
|
|
114
|
+
|
|
115
|
+
# Export data
|
|
116
|
+
export = await client.analytics.export("csv", project_id=project_id)
|
|
117
|
+
print(export.download_url)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Evaluations
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
# Trigger evaluations on a run
|
|
124
|
+
result = await client.evaluations.run(run_id, evaluators=["correctness", "hallucination"])
|
|
125
|
+
print(result.status, result.total_evaluated)
|
|
126
|
+
|
|
127
|
+
# Get evaluation summary for a project
|
|
128
|
+
summary = await client.evaluations.summary(project_id, period="7d")
|
|
129
|
+
print(summary.avg_score, summary.scores_by_evaluator)
|
|
130
|
+
|
|
131
|
+
# List evaluators configured for a project
|
|
132
|
+
evaluators = await client.evaluations.evaluators(project_id)
|
|
133
|
+
for ev in evaluators:
|
|
134
|
+
print(ev.type, ev.name)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Pagination
|
|
138
|
+
|
|
139
|
+
List methods return a `Page[T]` object:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
page = await client.projects.list(limit=20, offset=0)
|
|
143
|
+
print(page.total, page.has_more)
|
|
144
|
+
projects = page.items # list[Project]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Configuration
|
|
148
|
+
|
|
149
|
+
| Parameter | Environment variable | Description |
|
|
150
|
+
|-----------|---------------------|-------------|
|
|
151
|
+
| `api_key` | `PALQEE_PRISMA_API_KEY` | API key (`pq_prisma_sk_...`) |
|
|
152
|
+
| `workspace_id` | `PALQEE_PRISMA_WORKSPACE_ID` | Workspace UUID |
|
|
153
|
+
| `base_url` | `PALQEE_PRISMA_BASE_URL` | API gateway base URL |
|
|
154
|
+
| `timeout` | — | Request timeout in seconds (default 30) |
|
|
155
|
+
| `max_retries` | — | Max retries for transient errors (default 2) |
|
|
156
|
+
|
|
157
|
+
## Error handling
|
|
158
|
+
|
|
159
|
+
All exceptions inherit from `PrismaError`:
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from palqee_prisma_client import PrismaNotFoundError, PrismaAPIError, PrismaError
|
|
163
|
+
|
|
164
|
+
try:
|
|
165
|
+
project = await client.projects.get(project_id)
|
|
166
|
+
except PrismaNotFoundError:
|
|
167
|
+
print("Project not found")
|
|
168
|
+
except PrismaAPIError as e:
|
|
169
|
+
print(f"API error {e.status_code}: {e.message}")
|
|
170
|
+
except PrismaError:
|
|
171
|
+
print("SDK error")
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
| Exception | HTTP status | Description |
|
|
175
|
+
|-----------|-------------|-------------|
|
|
176
|
+
| `PrismaAuthenticationError` | — | Invalid or missing API key (client-side) |
|
|
177
|
+
| `PrismaAuthorizationError` | 401, 403 | Server rejected the credentials |
|
|
178
|
+
| `PrismaNotFoundError` | 404 | Resource does not exist |
|
|
179
|
+
| `PrismaConflictError` | 409 | Conflict with existing state |
|
|
180
|
+
| `PrismaUnprocessableEntityError` | 422 | Server-side validation failure |
|
|
181
|
+
| `PrismaAPIError` | other | Any other HTTP error |
|
|
182
|
+
| `PrismaTimeoutError` | — | Request timed out |
|
|
183
|
+
| `PrismaNetworkError` | — | Connection or transport failure |
|
|
184
|
+
| `PrismaValidationError` | — | Client-side input validation failure |
|
|
185
|
+
|
|
186
|
+
## Version
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from palqee_prisma_client import __version__
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# palqee-prisma-client
|
|
2
|
+
|
|
3
|
+
Python client for the Prisma AI platform. Provides async access to projects, runs, analytics, and evaluations through a typed API.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Python 3.10 or later
|
|
8
|
+
- A Prisma AI API key
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install palqee-prisma-client
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from palqee_prisma_client import PrismaClient
|
|
20
|
+
|
|
21
|
+
async with PrismaClient(
|
|
22
|
+
api_key="pq_prisma_sk_...",
|
|
23
|
+
workspace_id="<workspace-uuid>",
|
|
24
|
+
base_url="https://your-prisma-host",
|
|
25
|
+
) as client:
|
|
26
|
+
# Create a project and a run
|
|
27
|
+
project = await client.projects.get_or_create("my-app")
|
|
28
|
+
run = await client.runs.create(project.id)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Projects
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
# List all projects in the workspace
|
|
35
|
+
page = await client.projects.list()
|
|
36
|
+
for project in page.items:
|
|
37
|
+
print(project.id, project.name)
|
|
38
|
+
|
|
39
|
+
# Get a single project
|
|
40
|
+
project = await client.projects.get(project_id)
|
|
41
|
+
|
|
42
|
+
# Update a project
|
|
43
|
+
project = await client.projects.update(project_id, name="new-name", description="...")
|
|
44
|
+
|
|
45
|
+
# Get aggregate stats
|
|
46
|
+
stats = await client.projects.stats(project_id)
|
|
47
|
+
print(stats.total_runs, stats.total_traces)
|
|
48
|
+
|
|
49
|
+
# Delete a project
|
|
50
|
+
await client.projects.delete(project_id)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Runs
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
# List runs in a project (with optional filters)
|
|
57
|
+
page = await client.runs.list(project_id, status="completed", limit=50)
|
|
58
|
+
for run in page.items:
|
|
59
|
+
print(run.id, run.status)
|
|
60
|
+
|
|
61
|
+
# Get a single run
|
|
62
|
+
run = await client.runs.get(run_id)
|
|
63
|
+
|
|
64
|
+
# Update a run
|
|
65
|
+
run = await client.runs.update(run_id, status="completed")
|
|
66
|
+
|
|
67
|
+
# Get stats and evaluation metrics
|
|
68
|
+
stats = await client.runs.stats(run_id)
|
|
69
|
+
metrics = await client.runs.metrics(run_id)
|
|
70
|
+
print(metrics.metrics) # {"correctness": 0.88, ...}
|
|
71
|
+
|
|
72
|
+
# Delete a run
|
|
73
|
+
await client.runs.delete(run_id)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Analytics
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# Structured query
|
|
80
|
+
result = await client.analytics.query(
|
|
81
|
+
dimensions=["model_name"],
|
|
82
|
+
measures=["trace_count", "avg_latency_ms"],
|
|
83
|
+
filters=[{"field": "project_id", "op": "eq", "value": project_id}],
|
|
84
|
+
)
|
|
85
|
+
for row in result.rows:
|
|
86
|
+
print(row.dimensions, row.measures)
|
|
87
|
+
|
|
88
|
+
# Project overview
|
|
89
|
+
overview = await client.analytics.overview(project_id, period="7d")
|
|
90
|
+
print(overview.total_traces, overview.total_cost_usd)
|
|
91
|
+
|
|
92
|
+
# Cost breakdown
|
|
93
|
+
costs = await client.analytics.costs(project_id, period="30d")
|
|
94
|
+
for item in costs.breakdown:
|
|
95
|
+
print(item.label, item.cost_usd)
|
|
96
|
+
|
|
97
|
+
# Export data
|
|
98
|
+
export = await client.analytics.export("csv", project_id=project_id)
|
|
99
|
+
print(export.download_url)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Evaluations
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
# Trigger evaluations on a run
|
|
106
|
+
result = await client.evaluations.run(run_id, evaluators=["correctness", "hallucination"])
|
|
107
|
+
print(result.status, result.total_evaluated)
|
|
108
|
+
|
|
109
|
+
# Get evaluation summary for a project
|
|
110
|
+
summary = await client.evaluations.summary(project_id, period="7d")
|
|
111
|
+
print(summary.avg_score, summary.scores_by_evaluator)
|
|
112
|
+
|
|
113
|
+
# List evaluators configured for a project
|
|
114
|
+
evaluators = await client.evaluations.evaluators(project_id)
|
|
115
|
+
for ev in evaluators:
|
|
116
|
+
print(ev.type, ev.name)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Pagination
|
|
120
|
+
|
|
121
|
+
List methods return a `Page[T]` object:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
page = await client.projects.list(limit=20, offset=0)
|
|
125
|
+
print(page.total, page.has_more)
|
|
126
|
+
projects = page.items # list[Project]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Configuration
|
|
130
|
+
|
|
131
|
+
| Parameter | Environment variable | Description |
|
|
132
|
+
|-----------|---------------------|-------------|
|
|
133
|
+
| `api_key` | `PALQEE_PRISMA_API_KEY` | API key (`pq_prisma_sk_...`) |
|
|
134
|
+
| `workspace_id` | `PALQEE_PRISMA_WORKSPACE_ID` | Workspace UUID |
|
|
135
|
+
| `base_url` | `PALQEE_PRISMA_BASE_URL` | API gateway base URL |
|
|
136
|
+
| `timeout` | — | Request timeout in seconds (default 30) |
|
|
137
|
+
| `max_retries` | — | Max retries for transient errors (default 2) |
|
|
138
|
+
|
|
139
|
+
## Error handling
|
|
140
|
+
|
|
141
|
+
All exceptions inherit from `PrismaError`:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from palqee_prisma_client import PrismaNotFoundError, PrismaAPIError, PrismaError
|
|
145
|
+
|
|
146
|
+
try:
|
|
147
|
+
project = await client.projects.get(project_id)
|
|
148
|
+
except PrismaNotFoundError:
|
|
149
|
+
print("Project not found")
|
|
150
|
+
except PrismaAPIError as e:
|
|
151
|
+
print(f"API error {e.status_code}: {e.message}")
|
|
152
|
+
except PrismaError:
|
|
153
|
+
print("SDK error")
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Exception | HTTP status | Description |
|
|
157
|
+
|-----------|-------------|-------------|
|
|
158
|
+
| `PrismaAuthenticationError` | — | Invalid or missing API key (client-side) |
|
|
159
|
+
| `PrismaAuthorizationError` | 401, 403 | Server rejected the credentials |
|
|
160
|
+
| `PrismaNotFoundError` | 404 | Resource does not exist |
|
|
161
|
+
| `PrismaConflictError` | 409 | Conflict with existing state |
|
|
162
|
+
| `PrismaUnprocessableEntityError` | 422 | Server-side validation failure |
|
|
163
|
+
| `PrismaAPIError` | other | Any other HTTP error |
|
|
164
|
+
| `PrismaTimeoutError` | — | Request timed out |
|
|
165
|
+
| `PrismaNetworkError` | — | Connection or transport failure |
|
|
166
|
+
| `PrismaValidationError` | — | Client-side input validation failure |
|
|
167
|
+
|
|
168
|
+
## Version
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from palqee_prisma_client import __version__
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "hatchling.build"
|
|
3
|
+
requires = ["hatchling"]
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
authors = [
|
|
7
|
+
{name = "Hartley Jean-Aime", email = "hartley@palqee.com"},
|
|
8
|
+
]
|
|
9
|
+
dependencies = [
|
|
10
|
+
"httpx>=0.27",
|
|
11
|
+
"pydantic>=2.0",
|
|
12
|
+
]
|
|
13
|
+
description = "Prisma AI platform client for evaluations, datasets, and jobs"
|
|
14
|
+
license = "MIT"
|
|
15
|
+
name = "palqee-prisma-client"
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
requires-python = ">=3.10"
|
|
18
|
+
dynamic = ["version"]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
dev = [
|
|
22
|
+
"pytest>=8.0",
|
|
23
|
+
"pytest-asyncio>=0.23",
|
|
24
|
+
"pytest-cov>=5.0",
|
|
25
|
+
"respx>=0.21",
|
|
26
|
+
"ruff>=0.4",
|
|
27
|
+
"mypy>=1.0.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
asyncio_mode = "auto"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.version]
|
|
34
|
+
path = "src/palqee_prisma_client/version.py"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["src/palqee_prisma_client"]
|
|
38
|
+
|
|
39
|
+
[tool.ruff]
|
|
40
|
+
line-length = 100
|
|
41
|
+
target-version = "py310"
|
|
42
|
+
|
|
43
|
+
[tool.ruff.lint]
|
|
44
|
+
select = ["E", "F", "I", "N", "B", "W", "C4", "UP", "RUF"]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[pytest]
|
|
2
|
+
testpaths = tests
|
|
3
|
+
python_files = test_*.py
|
|
4
|
+
python_classes = Test*
|
|
5
|
+
python_functions = test_*
|
|
6
|
+
|
|
7
|
+
# Test discovery
|
|
8
|
+
norecursedirs = .* build dist CVS _darcs {arch} *.egg venv env
|
|
9
|
+
|
|
10
|
+
# Test execution
|
|
11
|
+
addopts =
|
|
12
|
+
--verbose
|
|
13
|
+
--tb=short
|
|
14
|
+
--strict-markers
|
|
15
|
+
--cov=palqee_prisma_client
|
|
16
|
+
--cov-report=term-missing
|
|
17
|
+
--cov-report=html
|
|
18
|
+
--cov-report=xml
|
|
19
|
+
--cov-config=.coveragerc
|
|
20
|
+
--cov-fail-under=60
|
|
21
|
+
--no-cov-on-fail
|
|
22
|
+
|
|
23
|
+
# Markers
|
|
24
|
+
markers =
|
|
25
|
+
unit: Unit tests
|
|
26
|
+
integration: Integration tests
|
|
27
|
+
|
|
28
|
+
# Async
|
|
29
|
+
asyncio_mode = auto
|
|
30
|
+
|
|
31
|
+
# Logging
|
|
32
|
+
log_cli = true
|
|
33
|
+
log_cli_level = INFO
|
|
34
|
+
log_cli_format = %(asctime)s [%(levelname)s] %(message)s (%(filename)s:%(lineno)s)
|
|
35
|
+
log_cli_date_format = %Y-%m-%d %H:%M:%S
|