Skip to main content

mathdatiao-agent native Python bindings

mathdatiao-agent is a competition project distribution from the mathdatiao contributors. It is not an official InternLM or Shanghai AI Laboratory distribution. Intern-S1 and the official Challenge Cup runner remain external upstream components with their own provenance and licenses.

The distribution is named mathdatiao-agent; its import namespace remains internlm so the competition user_agent.py compatibility layer does not need to own or duplicate the Rust runtime. The wheel contains the project's PyO3 extension and its small Python shim only. SymPy, Z3, Lean and other mathematics tools are deliberately not bundled into this wheel.

It is built with PyO3 0.21 and maturin 1.14.1 as one abi3 wheel per platform for Python 3.10 and newer.

Install

pip install ./mathdatiao_agent-0.1.1-cp310-abi3-<platform>.whl

The wheel is abi3 (compiled against the Python 3.10 stable ABI), so one platform wheel covers all supported CPython 3.10+ interpreters. A wheel tag still has to match the operating system and architecture; abi3 does not make a Linux wheel portable to macOS or Windows.

To build from source (e.g. for development):

# inside backend/ecosystem/internlm-py/
maturin develop --release
pytest tests/ -v

Building requires Rust and maturin. Installing a pre-built wheel does not: the installed runtime must not invoke Cargo, download a tool, or start a sidecar process. Publication is intentionally a separate, explicitly authorized release step; local verification never uploads to PyPI.

The reproducible Linux release build uses a caller-owned target, path remapping, auditwheel checking, and the checked-in top-level SPDX declaration:

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
export CARGO_TARGET_DIR="$HOME/.cache/mathdatiao-target-wheel"
export RUSTFLAGS="--remap-path-prefix=$PWD=. \
  --remap-path-prefix=$HOME/.cargo/registry/src=cargo-registry \
  --remap-path-prefix=$HOME/.cargo/git/checkouts=cargo-git"
uvx --from 'maturin==1.14.1' maturin build \
  --release --locked \
  --auditwheel check \
  --manifest-path backend/ecosystem/internlm-py/Cargo.toml \
  --sbom-include \
backend/ecosystem/internlm-py/tests/release/mathdatiao-agent.spdx.json

Do not relabel the result to an older manylinux baseline. The current locked graph includes a native-tls path through context AI support; a Zig manylinux2014 build therefore requires a separately reviewed OpenSSL static-vendoring or dependency-feature change. Until that is resolved, use the lowest tag reported by maturin and confirmed by auditwheel show.

Before handing a wheel to the release integrator, run the backend's offline artifact gate. It verifies metadata, abi3/native tags, every RECORD digest, license files, SBOM members, and forbidden source/build files. If the declared platform floor is not proven, the report is explicit_unavailable; never rename the wheel to claim portability:

python3 backend/scripts/audit_wheel.py \
  /absolute/path/mathdatiao_agent-*.whl \
  --platform-floor manylinux_2_17 \
  --output backend/reports/distribution-audit-<run-id>.json

Quickstart

import internlm

client = internlm.Client("replace-with-token")
req = (
    internlm.ChatRequest("intern-latest")
    .message(internlm.Message.user("hello"))
    .temperature(0.3)
    .build()
)
print(client.create(req))                       # blocking
# or, from an async def:
#   text = await client.create_async(req)

Streaming

def on_delta(text: str) -> None:
    print(text, end="", flush=True)

client.stream_sync(req, on_delta)

Context engineering

ContextManager is a thin in-memory wrapper over internlm::context_engineering::ContextManager. It exposes append, select, and turn-count inspection. The on-disk FileKV-backed path is intentionally not exposed in this revision; long-lived host processes that need it can drive the Rust API directly.

ctx = internlm.ContextManager("thread-1", max_tokens=8000)
ctx.append(internlm.Message.user("hi"))
ctx.append(internlm.Message.assistant("hello!"))
for turn in ctx.select():
    print(turn["role"], turn["content"])

Token estimation

est = internlm.TokenEstimator.heuristic()
est.estimate("hello, world!")                    # -> 3
gpt = internlm.TokenEstimator.tiktoken("gpt-4o")
gpt.estimate("hello, world!")                   # -> 4
gpt.name()                                      # -> "tiktoken"

API overview

Class Wraps
Client internlm::Client (async)
Message internlm::types::chat::Message
ChatRequest internlm::types::chat::ChatRequestBuilder
ChatRequestRef internlm::types::chat::ChatRequest
ContextManager internlm::context_engineering::ContextManager
TokenEstimator internlm::token_estimator::Heuristic/Tiktoken

Both blocking (create) and async (create_async) variants are exposed on Client; the async path is a coroutine that runs on the same tokio reactor the Rust SDK uses internally.

Distribution boundary

The wheel is the native Tokitai ABI, not a complete competition submission. The official client.chat object and in-process tool callback are supplied by the thin user_agent.py bridge. External mathematics packages are installed from their own official Python distributions and remain independently licensed. They must not be copied into this wheel.

License

MIT OR Apache-2.0, same as the underlying Rust crate.

Metadata

Release files for mathdatiao-agent 0.1.1

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

Built distributions (wheels)

Table of built distributions (wheels) for mathdatiao-agent 0.1.1
File Interpreter ABI Platform Actions
mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Total release size: 16.0 MB

Release files / mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 8.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9d025b2a9449361fa6b79d7ebf1421b332bb6cbab459c9445c4147f0586a0f56
BLAKE2b-256 checksum
How to use checksums
de3764ed12227048f7561e84dda1c93768d2362a99744ce174ac191cc5699e01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mathdatiao_agent-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 7.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0fff16756cc84b37b293cabbba9ee09fe634bd72b3630141d74a10198a01d6bf
BLAKE2b-256 checksum
How to use checksums
cfc1931f8c12385fd57458781580099965deaad45d0f6f36d4506836da5eb15a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for mathdatiao-agent 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