No project description provided
Project description
Agency Python SDK
Python client SDK for the GTS Agency platform. Provides typed HTTP clients for datasets, datasources, files, ontologies, prompts, and rules APIs.
Installation
pip install gts-agency-python-sdk
For development:
pip install -e ".[dev]"
Optional OpenTelemetry tracing support (Langfuse backend):
pip install gts-agency-python-sdk[observability]
Configuration
The examples in this repository use the following environment variables for authentication and configuration:
AGENCY_AUTH_URL: The OAuth2 token endpoint URL.AGENCY_API_URL: The base URL for the Agency API.AGENCY_ORG_ID: The organization ID to use for requests.AGENCY_CLIENT_ID: Your OAuth2 client ID.AGENCY_CLIENT_SECRET: Your OAuth2 client secret.
Usage
from agency_sdk.client import AgencyClient, CredentialsSupplier
credentials = CredentialsSupplier(
auth_base_url="https://auth.example.com",
client_id="your-client-id",
client_secret="your-client-secret",
)
client = AgencyClient(token_supplier=credentials, base_url="https://api.example.com")
Delegate Clients
Access each API domain through the facade:
client.dataset()— datasets CRUD, filesystem traversal, cloneclient.datasource()— datasource and table introspectionclient.files()— tenant file storage: list, upload, folder management, delete, signed URLs,gtsf://URI resolution, streamed downloadclient.ontology()— ontology export (JSON, Turtle, ISON) and entity-datasource mappingsclient.prompts()— prompt CRUD via command patternclient.rules()— rule listing, detail, execution, and execution historyclient.session_vault()— session-scoped key/value vault for agent state (classification-based encryption, audited reveal)client.gateway(org_id=..., gateway_base_url=...)— OpenAI-compatible LLM calls routed through the org's agentgateway (shared credentials +x-orgrouting header)
Rules Example
from agency_sdk.delegates.rules_dto import ExecuteRequest
rules = client.rules()
# List rules
result = rules.list(organisation_id=2)
for rule in result.items:
print(f"{rule.name} (status={rule.active_version_status})")
# Get rule detail
detail = rules.get(rule_id="rule-id", organisation_id=2)
# Execute a rule
response = rules.execute(
rule_id="rule-id",
request=ExecuteRequest(organisation=2, context={"key": "value"}, trace=True),
)
print(f"Result: {response.result}")
# List execution history
executions = rules.list_executions(rule_id="rule-id", organisation_id=2)
Files Example
files = client.files()
# Upload into a folder (multipart; up to 100 MiB per file and per request)
result = files.upload(organisation_id=2, file_paths=["report.pdf"], path="guidelines")
file_id = result.uploaded[0].id
# Resolve a gtsf:// reference (as found in configurations and rule annotations)
signed = files.resolve_gtsf_uri(f"gtsf://{file_id}", organisation_id=2)
print(f"Download until {signed.expires_at}: {signed.signed_url}")
# Or download directly (streamed to disk via the signed URL)
files.download(file_id=file_id, organisation_id=2, target_path="./report.pdf")
See docs/files_storage_flows.md for the full upload/download architecture.
Observability Example
Opt-in OpenTelemetry tracing + log correlation, shipped to a Langfuse backend and
authenticated with the same credentials as the API client. Requires the
[observability] extra.
obs = client.observability("gts-myagent") # reuses credentials; host defaults to base_url
tracer = obs.init() # exporters live; stdlib logging bridged
with obs.agent_run("agent.myagent", correlation_id=cid) as span:
logger.info("doing work") # stamped with the span's trace id
result = do_work()
See docs/observability.md for the full setup, the API, and migration from a per-agent bootstrap.
Agent Gateway Example
LLM calls routed through the org's deployed agentgateway — one m2m credential
instead of per-provider API keys. The gateway lives on its own host (not the
control-plane base_url); the SDK wires the rotating bearer, the x-org routing
header, and the URL into a standard openai client and hands it back.
gateway = client.gateway(org_id="2", gateway_base_url="http://localhost:4000")
oai = gateway.openai_client() # standard openai.OpenAI, pre-wired to the gateway
r = oai.chat.completions.create(
model="biglambda1", # virtual-model name from the org's gateway config
messages=[{"role": "user", "content": "Summarize this rule ..."}],
temperature=0.0,
)
# Streaming / tools / structured outputs — plain openai SDK
for chunk in oai.chat.completions.create(model="biglambda1", messages=[...], stream=True):
...
# Async (e.g. httpx-based agents)
aoai = gateway.async_openai_client()
See docs/gateway.md for prod/test URL selection, URL discovery, rotation-safe DIY openai wiring, and error semantics.
Examples
export AGENCY_AUTH_URL="http://localhost:8080/realms/agency/protocol/openid-connect/token"
export AGENCY_API_URL="http://localhost:13001"
export AGENCY_ORG_ID="2"
export AGENCY_CLIENT_ID="your-client-id"
export AGENCY_CLIENT_SECRET="your-client-secret"
python examples/quick_clone_dataset.py
python examples/quick_create_prompt.py
python examples/quick_export_ontology.py
python examples/quick_execute_rule.py
python examples/quick_files.py
python examples/quick_observability.py # requires the [observability] extra
python examples/quick_gateway.py # needs GATEWAY_BASE_URL (+ GATEWAY_MODEL); local gateway on :4000
To verify the SDK end to end against the local platform stack
(gts-local-environment), follow docs/local_e2e.md.
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
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 gts_agency_python_sdk-0.0.1rc11.tar.gz.
File metadata
- Download URL: gts_agency_python_sdk-0.0.1rc11.tar.gz
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bc60e952a085357393dc02dcb584663b3e5e0ace67665ebed01120a0b3ab7d1
|
|
| MD5 |
9873bdd7ce533361cfe13e9294984ac1
|
|
| BLAKE2b-256 |
701761634d0b50163db916bcaf541e48d3fe83cdc8a06e6e158f285db252c613
|
Provenance
The following attestation bundles were made for gts_agency_python_sdk-0.0.1rc11.tar.gz:
Publisher:
publish.yaml on groundtruthsystems/gts-agency_python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gts_agency_python_sdk-0.0.1rc11.tar.gz -
Subject digest:
6bc60e952a085357393dc02dcb584663b3e5e0ace67665ebed01120a0b3ab7d1 - Sigstore transparency entry: 2103642277
- Sigstore integration time:
-
Permalink:
groundtruthsystems/gts-agency_python-sdk@9aaf70781f5b6806ab02f61dc1198e20143c1f7a -
Branch / Tag:
refs/tags/v0.0.1rc11 - Owner: https://github.com/groundtruthsystems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@9aaf70781f5b6806ab02f61dc1198e20143c1f7a -
Trigger Event:
push
-
Statement type:
File details
Details for the file gts_agency_python_sdk-0.0.1rc11-py3-none-any.whl.
File metadata
- Download URL: gts_agency_python_sdk-0.0.1rc11-py3-none-any.whl
- Upload date:
- Size: 76.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cee33a6ce672344a4c8f9cdad3e167d4a251e5478b4ae2755a05e682b3ebc71
|
|
| MD5 |
c50b3b15c5d902165ce89d74ef135df3
|
|
| BLAKE2b-256 |
a29b7b955ded5c3125e384adb458b5b04215573b0fe889dd4413daab58d70c45
|
Provenance
The following attestation bundles were made for gts_agency_python_sdk-0.0.1rc11-py3-none-any.whl:
Publisher:
publish.yaml on groundtruthsystems/gts-agency_python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gts_agency_python_sdk-0.0.1rc11-py3-none-any.whl -
Subject digest:
2cee33a6ce672344a4c8f9cdad3e167d4a251e5478b4ae2755a05e682b3ebc71 - Sigstore transparency entry: 2103642609
- Sigstore integration time:
-
Permalink:
groundtruthsystems/gts-agency_python-sdk@9aaf70781f5b6806ab02f61dc1198e20143c1f7a -
Branch / Tag:
refs/tags/v0.0.1rc11 - Owner: https://github.com/groundtruthsystems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@9aaf70781f5b6806ab02f61dc1198e20143c1f7a -
Trigger Event:
push
-
Statement type: