probitas-api 0.1.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.
- probitas_api-0.1.0/LICENSE +72 -0
- probitas_api-0.1.0/PKG-INFO +65 -0
- probitas_api-0.1.0/README.md +53 -0
- probitas_api-0.1.0/pyproject.toml +22 -0
- probitas_api-0.1.0/setup.cfg +4 -0
- probitas_api-0.1.0/src/probitas/__init__.py +4 -0
- probitas_api-0.1.0/src/probitas/client.py +68 -0
- probitas_api-0.1.0/src/probitas/exceptions.py +6 -0
- probitas_api-0.1.0/src/probitas/resources/__init__.py +0 -0
- probitas_api-0.1.0/src/probitas/resources/v1/__init__.py +0 -0
- probitas_api-0.1.0/src/probitas/resources/v1/_uploads.py +48 -0
- probitas_api-0.1.0/src/probitas/resources/v1/calculate_risk.py +17 -0
- probitas_api-0.1.0/src/probitas/resources/v1/conflict_of_interest.py +29 -0
- probitas_api-0.1.0/src/probitas/resources/v1/construct_analysis.py +33 -0
- probitas_api-0.1.0/src/probitas/resources/v1/reports_comparison.py +13 -0
- probitas_api-0.1.0/src/probitas/resources/v1/reports_vector_embeddings.py +12 -0
- probitas_api-0.1.0/src/probitas/resources/v1/vector_comparison.py +10 -0
- probitas_api-0.1.0/src/probitas_api.egg-info/PKG-INFO +65 -0
- probitas_api-0.1.0/src/probitas_api.egg-info/SOURCES.txt +22 -0
- probitas_api-0.1.0/src/probitas_api.egg-info/dependency_links.txt +1 -0
- probitas_api-0.1.0/src/probitas_api.egg-info/requires.txt +1 -0
- probitas_api-0.1.0/src/probitas_api.egg-info/top_level.txt +2 -0
- probitas_api-0.1.0/src/tests/test_client.py +63 -0
- probitas_api-0.1.0/src/tests/test_multipart_fields.py +22 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# PROBITAS SDK — PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
**Copyright © 2026 PROBITAS. All rights reserved.**
|
|
4
|
+
|
|
5
|
+
## 1. Ownership
|
|
6
|
+
|
|
7
|
+
The PROBITAS API, including its source code, documentation, structure, and associated materials, is the intellectual property of its legitimate copyright holder ("Licensor").
|
|
8
|
+
|
|
9
|
+
Nothing in this License transfers ownership or intellectual property rights to the Licensee.
|
|
10
|
+
|
|
11
|
+
## 2. Grant of License
|
|
12
|
+
|
|
13
|
+
Subject to compliance with this License, the Licensor grants the Licensee a limited, non-exclusive, non-transferable, revocable license to install and use the PROBITAS API for authorized educational, research, testing, and institutional purposes.
|
|
14
|
+
|
|
15
|
+
This license does not grant unrestricted access to the PROBITAS platform or its services.
|
|
16
|
+
|
|
17
|
+
## 3. Permitted Activities
|
|
18
|
+
|
|
19
|
+
Unless otherwise restricted by a separate agreement, the Licensee may:
|
|
20
|
+
|
|
21
|
+
- Install and execute the SDK for authorized purposes.
|
|
22
|
+
- Integrate the SDK into internal applications for authorized institutional use.
|
|
23
|
+
- Modify local copies for internal testing and compatibility.
|
|
24
|
+
- Access publicly available documentation.
|
|
25
|
+
|
|
26
|
+
## 4. Restrictions
|
|
27
|
+
|
|
28
|
+
Without prior written authorization from the Licensor, the Licensee shall not:
|
|
29
|
+
|
|
30
|
+
- Sell, rent, lease, sublicense, or commercially redistribute the API.
|
|
31
|
+
- Distribute or publish copies of the API, whether modified or unmodified.
|
|
32
|
+
- Incorporate the API into commercial products or paid services.
|
|
33
|
+
- Repackage, rebrand, or distribute the API as an independently developed product.
|
|
34
|
+
- Remove, alter, or conceal copyright notices and proprietary attribution.
|
|
35
|
+
- Reverse engineer or attempt to circumvent technical access restrictions, except where applicable law expressly permits such activity.
|
|
36
|
+
- Use the API to develop or distribute unauthorized competing products using PROBITAS proprietary materials.
|
|
37
|
+
|
|
38
|
+
## 5. Commercial Authorization
|
|
39
|
+
|
|
40
|
+
Commercial use, commercial integration, redistribution, sublicensing, or other activities outside the permitted scope require prior written authorization from the Licensor.
|
|
41
|
+
|
|
42
|
+
The Licensor reserves the right to establish separate commercial licensing conditions.
|
|
43
|
+
|
|
44
|
+
## 6. Platform Access
|
|
45
|
+
|
|
46
|
+
Possession, installation, or use of the SDK does not automatically authorize access to the PROBITAS platform, API services, or Analytics Module (AM).
|
|
47
|
+
|
|
48
|
+
Platform access is governed separately by the PROBITAS Terms of Service and applicable authorization policies.
|
|
49
|
+
|
|
50
|
+
## 7. Termination
|
|
51
|
+
|
|
52
|
+
This License may be terminated upon material breach of its terms, subject to applicable law and any required notice or cure period.
|
|
53
|
+
|
|
54
|
+
Upon termination, the Licensee must cease activities no longer authorized under this License and comply with applicable instructions concerning copies of the SDK.
|
|
55
|
+
|
|
56
|
+
## 8. Disclaimer of Warranty
|
|
57
|
+
|
|
58
|
+
THE SDK IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW.
|
|
59
|
+
|
|
60
|
+
The Licensor does not guarantee uninterrupted availability, error-free operation, or suitability for a particular purpose.
|
|
61
|
+
|
|
62
|
+
## 9. Limitation of Liability
|
|
63
|
+
|
|
64
|
+
To the maximum extent permitted by applicable law, the Licensor shall not be liable for indirect, incidental, special, consequential, or punitive damages arising from the use or inability to use the SDK and API.
|
|
65
|
+
|
|
66
|
+
Nothing in this section excludes liability that cannot lawfully be excluded.
|
|
67
|
+
|
|
68
|
+
## 10. Permissions and Contact
|
|
69
|
+
|
|
70
|
+
Requests for commercial authorization, redistribution rights, or other permissions outside this License must be submitted to the legitimate copyright holder through its designated contact channel.
|
|
71
|
+
|
|
72
|
+
**All rights not expressly granted under this License are reserved.**
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: probitas-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the PROBITAS API
|
|
5
|
+
Author: PROBITAS Development Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: httpx>=0.27.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# PROBITAS Python SDK
|
|
14
|
+
|
|
15
|
+
A Python SDK for interacting with the PROBITAS API.
|
|
16
|
+
|
|
17
|
+
PROBITAS provides an API interface for behavioral analytics and risk assessment workflows.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install probitas
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from probitas import Probitas
|
|
29
|
+
|
|
30
|
+
client = Probitas(
|
|
31
|
+
api_key="YOUR_API_KEY",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Calculate project risk
|
|
35
|
+
result = client.calculate_risk()
|
|
36
|
+
|
|
37
|
+
print(result)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Available Services
|
|
41
|
+
|
|
42
|
+
The SDK provides access to the following PROBITAS API services:
|
|
43
|
+
|
|
44
|
+
- Risk calculation
|
|
45
|
+
- Conflict-of-interest screening
|
|
46
|
+
- Construct analysis
|
|
47
|
+
- Reports comparison
|
|
48
|
+
- Reports vector embeddings
|
|
49
|
+
- Vector comparison
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Authentication
|
|
54
|
+
|
|
55
|
+
The SDK authenticates requests using your PROBITAS API key.
|
|
56
|
+
|
|
57
|
+
Keep your API key private. Do not commit credentials to source control or expose them in public repositories.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
- Python 3.10 or later
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
See the LICENSE file for licensing information.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# PROBITAS Python SDK
|
|
2
|
+
|
|
3
|
+
A Python SDK for interacting with the PROBITAS API.
|
|
4
|
+
|
|
5
|
+
PROBITAS provides an API interface for behavioral analytics and risk assessment workflows.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install probitas
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from probitas import Probitas
|
|
17
|
+
|
|
18
|
+
client = Probitas(
|
|
19
|
+
api_key="YOUR_API_KEY",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Calculate project risk
|
|
23
|
+
result = client.calculate_risk()
|
|
24
|
+
|
|
25
|
+
print(result)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Available Services
|
|
29
|
+
|
|
30
|
+
The SDK provides access to the following PROBITAS API services:
|
|
31
|
+
|
|
32
|
+
- Risk calculation
|
|
33
|
+
- Conflict-of-interest screening
|
|
34
|
+
- Construct analysis
|
|
35
|
+
- Reports comparison
|
|
36
|
+
- Reports vector embeddings
|
|
37
|
+
- Vector comparison
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Authentication
|
|
42
|
+
|
|
43
|
+
The SDK authenticates requests using your PROBITAS API key.
|
|
44
|
+
|
|
45
|
+
Keep your API key private. Do not commit credentials to source control or expose them in public repositories.
|
|
46
|
+
|
|
47
|
+
## Requirements
|
|
48
|
+
|
|
49
|
+
- Python 3.10 or later
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
See the LICENSE file for licensing information.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "probitas-api"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the PROBITAS API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "PROBITAS Development Team" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
dependencies = [
|
|
18
|
+
"httpx>=0.27.0"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.packages.find]
|
|
22
|
+
where = ["src"]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
from probitas.exceptions import ProbitasAPIError
|
|
3
|
+
from probitas.resources.v1 import (
|
|
4
|
+
api_keys,
|
|
5
|
+
reports_vector_embeddings,
|
|
6
|
+
calculate_risk,
|
|
7
|
+
construct_analysis,
|
|
8
|
+
conflict_of_interest,
|
|
9
|
+
reports_comparison,
|
|
10
|
+
vector_comparison,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
class Probitas:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
api_key: str,
|
|
17
|
+
base_url: str = "https://api.probitas.com/v1/api/",
|
|
18
|
+
timeout: float = 30.0,
|
|
19
|
+
transport=None,
|
|
20
|
+
):
|
|
21
|
+
|
|
22
|
+
self.client = httpx.Client(
|
|
23
|
+
base_url=base_url,
|
|
24
|
+
headers={
|
|
25
|
+
"Authorization": f"ApiKey {api_key}",
|
|
26
|
+
"Accept": "application/json",
|
|
27
|
+
},
|
|
28
|
+
timeout=timeout,
|
|
29
|
+
transport=transport,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
self.calculate_risk = calculate_risk.CalculateRisk(self)
|
|
33
|
+
self.conflict_of_interest = conflict_of_interest.ConflictofInterest(self)
|
|
34
|
+
self.construct_analysis = construct_analysis.ConstructAnalysis(self)
|
|
35
|
+
self.reports_comparison = reports_comparison.ReportsComparison(self)
|
|
36
|
+
self.reports_vector_embeddings = reports_vector_embeddings.ReportsVectorEmbeddings(self)
|
|
37
|
+
self.vector_comparison = vector_comparison.VectorComparison(self)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def request(self, method: str, endpoint: str, **kwargs):
|
|
41
|
+
response = self.client.request(method, endpoint, **kwargs)
|
|
42
|
+
|
|
43
|
+
if not response.is_success:
|
|
44
|
+
try:
|
|
45
|
+
error_data = response.json()
|
|
46
|
+
except ValueError:
|
|
47
|
+
error_data = {"message": response.text}
|
|
48
|
+
|
|
49
|
+
message = error_data.get("message", error_data.get("detail", "An API error occurred."))
|
|
50
|
+
raise ProbitasAPIError(
|
|
51
|
+
message=message,
|
|
52
|
+
status_code=response.status_code,
|
|
53
|
+
response=error_data,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if response.status_code == 204:
|
|
57
|
+
return None
|
|
58
|
+
return response.json()
|
|
59
|
+
|
|
60
|
+
def close(self):
|
|
61
|
+
self.client.close()
|
|
62
|
+
|
|
63
|
+
def __enter__(self):
|
|
64
|
+
return self
|
|
65
|
+
|
|
66
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
67
|
+
self.close()
|
|
68
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from contextlib import ExitStack
|
|
2
|
+
from os import PathLike
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def prepare_uploads(stack: ExitStack, field: str, uploads):
|
|
7
|
+
"""Build httpx multipart entries from paths, streams, bytes, or file tuples."""
|
|
8
|
+
entries = []
|
|
9
|
+
for index, upload in enumerate(uploads):
|
|
10
|
+
|
|
11
|
+
if isinstance(upload, (str, PathLike)):
|
|
12
|
+
path = Path(upload)
|
|
13
|
+
stream = stack.enter_context(path.open("rb"))
|
|
14
|
+
value = (path.name, stream)
|
|
15
|
+
|
|
16
|
+
elif isinstance(upload, bytes):
|
|
17
|
+
value = (f"upload-{index + 1}", upload)
|
|
18
|
+
|
|
19
|
+
else:
|
|
20
|
+
value = upload
|
|
21
|
+
entries.append((f"{field}[{index}]", value))
|
|
22
|
+
return entries
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def prepare_mapping_uploads(stack: ExitStack, field: str, uploads: dict):
|
|
26
|
+
entries = []
|
|
27
|
+
for key, upload in uploads.items():
|
|
28
|
+
if isinstance(upload, (str, PathLike)):
|
|
29
|
+
path = Path(upload)
|
|
30
|
+
stream = stack.enter_context(path.open("rb"))
|
|
31
|
+
value = (path.name, stream)
|
|
32
|
+
elif isinstance(upload, bytes):
|
|
33
|
+
value = (str(key), upload)
|
|
34
|
+
else:
|
|
35
|
+
value = upload
|
|
36
|
+
# DRF DictField's HTML form parser expects dot-separated keys
|
|
37
|
+
# (for example ``reports_files.case-1``), not bracket notation.
|
|
38
|
+
entries.append((f"{field}.{key}", value))
|
|
39
|
+
return entries
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def indexed_form_values(field: str, values):
|
|
43
|
+
return [(f"{field}[{index}]", value) for index, value in enumerate(values)]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def mapped_form_values(field: str, values: dict):
|
|
47
|
+
# Keep this encoding aligned with DRF's DictField multipart parser.
|
|
48
|
+
return [(f"{field}.{key}", value) for key, value in values.items()]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from datetime import date
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CalculateRisk:
|
|
5
|
+
def __init__(self, client):
|
|
6
|
+
self.client = client
|
|
7
|
+
|
|
8
|
+
def __call__(self, project_name: str, project_start_date: date, project_participants: dict):
|
|
9
|
+
return self.client.request(
|
|
10
|
+
"POST",
|
|
11
|
+
"calculate-risk/",
|
|
12
|
+
json = {
|
|
13
|
+
"project_name" : project_name,
|
|
14
|
+
"project_start_date" : project_start_date.isoformat(),
|
|
15
|
+
"project_participants": project_participants
|
|
16
|
+
}
|
|
17
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
class ConflictofInterest:
|
|
3
|
+
def __init__(self, client):
|
|
4
|
+
self.client = client
|
|
5
|
+
|
|
6
|
+
def screen_hr_conflict(self, reporter_ids: list, subject_ids: list, screener_ids: list):
|
|
7
|
+
return self.client.request(
|
|
8
|
+
"POST",
|
|
9
|
+
"conflict-interest-screening/",
|
|
10
|
+
json={
|
|
11
|
+
"reporter_ids" : reporter_ids,
|
|
12
|
+
"subject_ids" : subject_ids,
|
|
13
|
+
"screener_ids" : screener_ids,
|
|
14
|
+
"screening_type": "hr",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
def screen_approving_bodies_conflict(self, subject_ids: list, screener_ids: list):
|
|
20
|
+
return self.client.request(
|
|
21
|
+
"POST",
|
|
22
|
+
"conflict-interest-screening/",
|
|
23
|
+
json={
|
|
24
|
+
"subject_ids" : subject_ids,
|
|
25
|
+
"screener_ids" : screener_ids,
|
|
26
|
+
"screening_type": "approving_bodies",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from contextlib import ExitStack
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from probitas.resources.v1._uploads import (
|
|
5
|
+
indexed_form_values,
|
|
6
|
+
mapped_form_values,
|
|
7
|
+
prepare_uploads,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ConstructAnalysis:
|
|
12
|
+
def __init__(self, client):
|
|
13
|
+
self.client = client
|
|
14
|
+
|
|
15
|
+
def __call__(
|
|
16
|
+
self,
|
|
17
|
+
report_files: list,
|
|
18
|
+
hr_staff_ids: list,
|
|
19
|
+
submitted_validator_ids: list,
|
|
20
|
+
hr_assessments: dict,
|
|
21
|
+
report_images: Optional[list] = None,
|
|
22
|
+
report_image_urls: Optional[list] = None,
|
|
23
|
+
):
|
|
24
|
+
with ExitStack() as stack:
|
|
25
|
+
files = prepare_uploads(stack, "report_files", report_files)
|
|
26
|
+
files += prepare_uploads(stack, "report_images", report_images or [])
|
|
27
|
+
data = indexed_form_values("hr_staff_ids", hr_staff_ids)
|
|
28
|
+
data += indexed_form_values("submitted_validator_ids", submitted_validator_ids)
|
|
29
|
+
data += mapped_form_values("hr_assessments", hr_assessments)
|
|
30
|
+
data += indexed_form_values("report_image_urls", report_image_urls or [])
|
|
31
|
+
return self.client.request(
|
|
32
|
+
"POST", "construct-analysis/", files=files, data=data
|
|
33
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from contextlib import ExitStack
|
|
2
|
+
|
|
3
|
+
from probitas.resources.v1._uploads import prepare_mapping_uploads
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ReportsComparison:
|
|
7
|
+
def __init__(self, client):
|
|
8
|
+
self.client = client
|
|
9
|
+
|
|
10
|
+
def __call__(self, reports_files: dict):
|
|
11
|
+
with ExitStack() as stack:
|
|
12
|
+
files = prepare_mapping_uploads(stack, "reports_files", reports_files)
|
|
13
|
+
return self.client.request("POST", "report-comparison/", files=files)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: probitas-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the PROBITAS API
|
|
5
|
+
Author: PROBITAS Development Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: httpx>=0.27.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# PROBITAS Python SDK
|
|
14
|
+
|
|
15
|
+
A Python SDK for interacting with the PROBITAS API.
|
|
16
|
+
|
|
17
|
+
PROBITAS provides an API interface for behavioral analytics and risk assessment workflows.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install probitas
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from probitas import Probitas
|
|
29
|
+
|
|
30
|
+
client = Probitas(
|
|
31
|
+
api_key="YOUR_API_KEY",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Calculate project risk
|
|
35
|
+
result = client.calculate_risk()
|
|
36
|
+
|
|
37
|
+
print(result)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Available Services
|
|
41
|
+
|
|
42
|
+
The SDK provides access to the following PROBITAS API services:
|
|
43
|
+
|
|
44
|
+
- Risk calculation
|
|
45
|
+
- Conflict-of-interest screening
|
|
46
|
+
- Construct analysis
|
|
47
|
+
- Reports comparison
|
|
48
|
+
- Reports vector embeddings
|
|
49
|
+
- Vector comparison
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Authentication
|
|
54
|
+
|
|
55
|
+
The SDK authenticates requests using your PROBITAS API key.
|
|
56
|
+
|
|
57
|
+
Keep your API key private. Do not commit credentials to source control or expose them in public repositories.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
- Python 3.10 or later
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
See the LICENSE file for licensing information.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/probitas/__init__.py
|
|
5
|
+
src/probitas/client.py
|
|
6
|
+
src/probitas/exceptions.py
|
|
7
|
+
src/probitas/resources/__init__.py
|
|
8
|
+
src/probitas/resources/v1/__init__.py
|
|
9
|
+
src/probitas/resources/v1/_uploads.py
|
|
10
|
+
src/probitas/resources/v1/calculate_risk.py
|
|
11
|
+
src/probitas/resources/v1/conflict_of_interest.py
|
|
12
|
+
src/probitas/resources/v1/construct_analysis.py
|
|
13
|
+
src/probitas/resources/v1/reports_comparison.py
|
|
14
|
+
src/probitas/resources/v1/reports_vector_embeddings.py
|
|
15
|
+
src/probitas/resources/v1/vector_comparison.py
|
|
16
|
+
src/probitas_api.egg-info/PKG-INFO
|
|
17
|
+
src/probitas_api.egg-info/SOURCES.txt
|
|
18
|
+
src/probitas_api.egg-info/dependency_links.txt
|
|
19
|
+
src/probitas_api.egg-info/requires.txt
|
|
20
|
+
src/probitas_api.egg-info/top_level.txt
|
|
21
|
+
src/tests/test_client.py
|
|
22
|
+
src/tests/test_multipart_fields.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpx>=0.27.0
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
|
|
5
|
+
from probitas import Probitas, ProbitasAPIError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ProbitasClientTests(unittest.TestCase):
|
|
9
|
+
def test_resource_uses_api_route_and_auth_header(self):
|
|
10
|
+
seen = {}
|
|
11
|
+
|
|
12
|
+
def handler(request):
|
|
13
|
+
seen["path"] = request.url.path
|
|
14
|
+
seen["authorization"] = request.headers.get("authorization")
|
|
15
|
+
seen["body"] = request.read().decode()
|
|
16
|
+
return httpx.Response(200, json={"embedding": [0.1, 0.2]})
|
|
17
|
+
|
|
18
|
+
client = Probitas(
|
|
19
|
+
api_key="sample-key",
|
|
20
|
+
base_url="https://example.test/v1/api/",
|
|
21
|
+
transport=httpx.MockTransport(handler),
|
|
22
|
+
)
|
|
23
|
+
result = client.reports_vector_embeddings("summary")
|
|
24
|
+
|
|
25
|
+
self.assertEqual(result, {"embedding": [0.1, 0.2]})
|
|
26
|
+
self.assertEqual(seen["path"], "/v1/api/reports-vector-embeddings/")
|
|
27
|
+
self.assertEqual(seen["authorization"], "ApiKey sample-key")
|
|
28
|
+
self.assertIn('"report_summary":"summary"', seen["body"])
|
|
29
|
+
client.close()
|
|
30
|
+
|
|
31
|
+
def test_api_error_preserves_status_and_body(self):
|
|
32
|
+
client = Probitas(
|
|
33
|
+
api_key="sample-key",
|
|
34
|
+
base_url="https://example.test/v1/api/",
|
|
35
|
+
transport=httpx.MockTransport(
|
|
36
|
+
lambda request: httpx.Response(400, json={"detail": "invalid input"})
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
with self.assertRaises(ProbitasAPIError) as raised:
|
|
41
|
+
client.vector_comparison([[1.0, 0.0]])
|
|
42
|
+
|
|
43
|
+
self.assertEqual(raised.exception.status_code, 400)
|
|
44
|
+
self.assertEqual(raised.exception.response, {"detail": "invalid input"})
|
|
45
|
+
self.assertEqual(str(raised.exception), "invalid input")
|
|
46
|
+
client.close()
|
|
47
|
+
|
|
48
|
+
def test_context_manager_closes_transport(self):
|
|
49
|
+
client = Probitas(
|
|
50
|
+
api_key="sample-key",
|
|
51
|
+
base_url="https://example.test/v1/api/",
|
|
52
|
+
transport=httpx.MockTransport(
|
|
53
|
+
lambda request: httpx.Response(204)
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
with client as entered:
|
|
58
|
+
self.assertIs(entered, client)
|
|
59
|
+
self.assertTrue(client.client.is_closed)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
unittest.main()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from contextlib import ExitStack
|
|
3
|
+
|
|
4
|
+
from probitas.resources.v1._uploads import mapped_form_values, prepare_mapping_uploads
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MultipartFieldTests(unittest.TestCase):
|
|
8
|
+
def test_dictionary_values_use_drf_dictfield_notation(self):
|
|
9
|
+
fields = mapped_form_values("hr_assessments", {"validator-1": "review"})
|
|
10
|
+
self.assertEqual(fields, [("hr_assessments.validator-1", "review")])
|
|
11
|
+
|
|
12
|
+
def test_dictionary_uploads_use_drf_dictfield_notation(self):
|
|
13
|
+
fields = prepare_mapping_uploads(
|
|
14
|
+
ExitStack(),
|
|
15
|
+
"reports_files",
|
|
16
|
+
{"report-1": b"pdf"},
|
|
17
|
+
)
|
|
18
|
+
self.assertEqual(fields, [("reports_files.report-1", ("report-1", b"pdf"))])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
unittest.main()
|