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.0-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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mathdatiao_agent-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

File details

Details for the file mathdatiao_agent-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mathdatiao_agent-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26e84809b00c600c37fcd319c25cc342a25a904c975e761e82eb125c77e0acf2
MD5 1679b8b0cd1476d47f06198d20698ef3
BLAKE2b-256 e0ea465adf76bee1bf9ff472ea500f97b0849e7f6f35c4531f3bb8761e61afad

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

1 file

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