Skip to content
Draft
13 changes: 13 additions & 0 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.28.2", features = ["extension-module", "abi3-py38"] }
pyo3-async-runtimes = { version = "0.28", features = ["tokio-runtime"] }
tokio = { version = "1.42.0", features = ["full"] }
once_cell = "1.19"
serde_yaml = "0.9"
axum = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
futures = { workspace = true }
uuid = { workspace = true, features = ["v4"] }
tracing = { workspace = true }

[dependencies.smg]
path = "../../model_gateway"
Expand All @@ -32,6 +39,12 @@ workspace = true
[dependencies.reasoning-parser]
workspace = true

[dependencies.llm-tokenizer]
workspace = true

[dependencies.openai-protocol]
workspace = true

[features]
default = ["pyo3/extension-module"]
vendored-openssl = ["smg/vendored-openssl"]
Expand Down
13 changes: 13 additions & 0 deletions bindings/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

This directory contains the Python bindings for SMG (Shepherd Model Gateway), built using [maturin](https://github.com/PyO3/maturin) and [PyO3](https://github.com/PyO3/pyo3).

## Two consumption modes

These bindings serve two distinct use cases:

1. **smg as a Python-launched binary** — the historical use, documented in
[Quick Start](#quick-start) below. `smg serve` boots a router in-process.
2. **smg as a Python library** — used by inference engines that want smg's
protocol layer (tokenization, function calling, reasoning parser, OAI
server, MCP, response API) without owning the routing/gateway. The first
integration target is TokenSpeed; `tokenspeed serve` will `import smg_rs`
and call into the entry points in `src/serving.rs`. See the module
docstring there for the planned shape.

## Quick Start

### Installation
Expand Down
3 changes: 3 additions & 0 deletions bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use pyo3::prelude::*;
use smg::*;
use smg_auth as auth;

mod serving;

// Define the enums with PyO3 bindings
#[pyclass(eq, from_py_object)]
#[derive(Clone, PartialEq, Debug)]
Expand Down Expand Up @@ -1274,5 +1276,6 @@ fn smg_rs(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(print_banner, m)?)?;
m.add_function(wrap_pyfunction!(get_available_tool_call_parsers, m)?)?;
m.add_function(wrap_pyfunction!(get_available_reasoning_parsers, m)?)?;
serving::register(m)?;
Ok(())
}
Loading
Loading