Skip to main content

viewport-core

The shared runtime under Viewport Evals, HITL and Context. See the repository README.

pip install viewport-core   # or: uv add viewport-core

Example

Save this as example.py and run python example.py. It loads a YAML expectation, calls a tool that takes a card token, lets a tool server answer instead of running the tool, records the call under a fake clock and checks it:

import asyncio
import os

from pydantic import SecretStr

from viewportai.core import SpecError, compile_matcher, stable_json, tool, tool_server, trace
from viewportai.core.testing import FakeClock, SequentialIds
from viewportai.core.yaml import load_yaml

# A fixed demo key so the marker below is reproducible; real deployments use `openssl rand -hex 32`.
os.environ["VIEWPORT_REDACT_KEY"] = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"


@tool
async def charge_card(amount: float, card_token: SecretStr) -> dict[str, str]:
    """Charge a card."""
    raise RuntimeError("never runs: the tool server answers")


# One parser, written line for line in both languages: the same YAML loads to the same value everywhere.
expected = compile_matcher(load_yaml("tool_name: charge_card\nargs: { amount: { lte: 100 } }\n").value)


# The tool server answers where the tool body would run; Evals replays recorded results this way.
def replay(call: object) -> dict[str, object]:
    return {"result": {"charge_id": "ch_1"}}


async def main() -> None:
    async with trace(clock=FakeClock(), ids=SequentialIds()) as t:
        with tool_server(replay, warn=False):
            await charge_card(42.5, "tok_4242")

    call = t.trajectory.tool_calls()[0]
    print(call.id, call.started_at)
    print(stable_json(call.args))  # the server got "tok_4242"; the recording holds a marker
    print(stable_json(call.result), stable_json(call.attributes))
    print(expected.match(call).status)  # pass

    try:
        load_yaml("args:\n  amount: 1\n  amount: 2\n", file="case.yaml")
    except SpecError as err:
        print(err)


asyncio.run(main())

It prints:

evt_1 2026-01-01T00:00:00.000Z
{"amount":42.5,"card_token":"[redacted hmac:b6c02ec2b0f4]"}
{"charge_id":"ch_1"} {"viewport.tool.served":true}
pass
case.yaml is invalid (1 issue)
  case.yaml:3:3 args.amount: duplicate key "amount" (first at line 2)

Source, docs and the TypeScript twin: https://github.com/viewportai/core

Metadata

Release files for viewport-core 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for viewport-core 0.1.1
File Size Uploaded Provenance Actions
viewport_core-0.1.1.tar.gz 139.0 kB Without provenance Details for viewport_core-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for viewport-core 0.1.1
File Interpreter ABI Platform Actions
viewport_core-0.1.1-py3-none-any.whl Python 3 none any Details for viewport_core-0.1.1-py3-none-any.whl

Total release size: 293.4 kB

Release files / viewport_core-0.1.1.tar.gz

Download URL viewport_core-0.1.1.tar.gz
Size 139.0 kB
Tags Source
SHA-256 checksum
How to use checksums
adbec1c70f2078b1116f8acfc78261f78be21299436e62969f853c47ef5a2702
BLAKE2b-256 checksum
How to use checksums
5bf4d54b9817b5bb4f55d52e7f75da39e4322036f5fdfef8a7f54084bad924db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / viewport_core-0.1.1-py3-none-any.whl

Download URL viewport_core-0.1.1-py3-none-any.whl
Size 154.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cf4cd92b5091e1bc68b0c829993b2dde80cb85fa9763ad12ca4e27fca52cbe1
BLAKE2b-256 checksum
How to use checksums
9e2ae458f7310f1354dc7ad50306844159a514da0624ad1ed2bc178e3f9ec8b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for viewport-core 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page