Pyo3 - Langgraph Prove of Concept
This project is a proof of concept that you can use Langgraph just as easy as in Python, but in Rust instead, with the power of Pyo3.
Features
- A bare minimum chat interface built with
inquire. - A bare minimum graph that accepts user message and send it to
Ollama. - All chat history are perserved through one session.
How is It Done?
Go read the code :). JK, pyo3 is doing the heavy-lifting here. It allows you to use any Python packages just like in Python. Most of the time you are just translating Python code into Rust with 1:1 ratio, or 1:2 because it’s a little bit more verbose in Rust.
The streaming is a little bit tricky thought. In Python, you would do:
stream = streamer()
for chunk in stream:
print(chunk)
Bu…
Pyo3 - Langgraph Prove of Concept
This project is a proof of concept that you can use Langgraph just as easy as in Python, but in Rust instead, with the power of Pyo3.
Features
- A bare minimum chat interface built with
inquire. - A bare minimum graph that accepts user message and send it to
Ollama. - All chat history are perserved through one session.
How is It Done?
Go read the code :). JK, pyo3 is doing the heavy-lifting here. It allows you to use any Python packages just like in Python. Most of the time you are just translating Python code into Rust with 1:1 ratio, or 1:2 because it’s a little bit more verbose in Rust.
The streaming is a little bit tricky thought. In Python, you would do:
stream = streamer()
for chunk in stream:
print(chunk)
But in Rust, you need to tweak it just a little bit.
let stream = streamer.call0()?;
while let Ok(chunk) = stream.getattr(py, "__next__")?.call0(py) {
println!("{chunk}");
}
See? Really just a small tweak, but you are writing Rust now! Hooray!
Run It Yourself!
Requirements
- Rust >= 1.92
- Python >= 3.13
Setup
make init
Run
make dev
Showcases
Contribution
Feel free to open tickets and PRs! Do whatever you want with this knowledge. I mean it’s just a POC, and a showcase of the power of Rust community :)