Skip to main content

Python Bindings for Ambi

A Python native extension for the Ambi AI Agent framework.

Installation

From PyPI (recommended)

pip install ambi-python

Build from source

Requires maturin and a Rust toolchain.

# Install maturin
pip install maturin

# Build and install locally
cd bindings/python
maturin develop --release

Then import as:

from ambi import Agent, AgentState, Pipeline, LLMEngineConfig

Build & Publish

cd bindings/python

# Build wheel
maturin build --release

# Publish to PyPI
maturin publish --username __token__ --password pypi-xxxxx

The built .whl files will be in target/wheels/.

Examples

Run any example from the bindings/python directory:

cd bindings/python

# Basic cloud-based chat
OPENAI_API_KEY=sk-... python examples/chat-cloud.py

# Streaming output
OPENAI_API_KEY=sk-... python examples/chat-stream.py

# Tool calling
OPENAI_API_KEY=sk-... python examples/custom-tool.py

# Custom chat template
OPENAI_API_KEY=sk-... python examples/custom-template.py

# Custom Python LLM engine
python examples/custom-engine.py

# Memory eviction
OPENAI_API_KEY=sk-... python examples/memory-eviction.py

API Reference

Python JS equivalent Description
Agent.make(config) Agent.make(config) Create an async agent
agent.preamble("...") agent.preamble("...") Set system prompt
agent.template("chatml") agent.template(Chatml) Set template type
agent.custom_template(...) agent.customTemplate(...) Custom template
agent.add_tool(...) agent.tool(...) Register a tool
agent.with_standard_formatting() agent.withStandardFormatting() Enable standard formatting
agent.with_eviction_strategy(...) agent.withEvictionStrategy(...) Set eviction strategy
agent.count_tokens(...) agent.countTokens(...) Count tokens
AgentState("id") new AgentState("id") Create session state
LLMEngineConfig.openai(...) LLMEngineConfig.openai(...) OpenAI engine
LLMEngineConfig.custom(...) LLMEngineConfig.custom(...) Custom engine
Pipeline.chat_runner(n) Pipeline.chatRunner(n) Chat runner
Pipeline.custom(...) Pipeline.custom(...) Custom pipeline
runner.chat(...) runner.chat(...) Sync chat
runner.chat_stream(...) runner.chatStream(...) Streaming chat
resolve_request(id, result) resolveRequest(id, result) Resolve async callback
resolve_pipeline_request(...) resolvePipelineRequest(...) Resolve pipeline callback

Release files for ambi-python 0.1.1

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

Built distribution (wheel)

Table of built distributions (wheels) for ambi-python 0.1.1
File Interpreter ABI Platform
ambi_python-0.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details

Release files / ambi_python-0.1.1-cp312-cp312-win_amd64.whl

Download URL ambi_python-0.1.1-cp312-cp312-win_amd64.whl
Size 4.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f0508ffd0fa8f171d849c397071650c64a178f6f67c72c501e4a57ca901a21d2
BLAKE2b-256 checksum
How to use checksums
8154506a7d9469efdc1c30346f7755ec0a8a7a193626a6e54ee80fb232e47602
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release 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