I just want to know if it is possible to use a tatatui TUI with a python backend via maturin. If that’s the case how can I do the vinculation with the lib.rs that maturin creates ?
I’m trying to create a LLM agent, and since almost all frameworks are made for python or JS, I can’t just use only Rust, but I like what I can do with ratatui. It is possible to use a backend python with ratatui as a TUI that works like a frontend for the python script ? My project is just a cli tool for me, not a web development, but I want to use python as like a “backend” for my tool and ratatui as the “frontend”
This is a word that I can’t find much info on how to interpret it. Seems it has a meaning in Spanish / Portuguese I wonder if you can rephrase this to help understand what you meant here?
I’m not too aware of techniques for calling python code, but I’d expect that you might be able to use PyO3 to call python code from your app. Alternatively, if your script’s input and output are just stdin/out, then you could hook things up with std::process::Command
There’s also quite a few LLM libraries for Rust that are worth exploring, e.g. Kalosm/Floneum, SwiftIDE/Bosun, AIPack/Rust-genai, as well as various more LLM specific tools / api wrappers (e.g. async-openai) and people doing stuff similar to langchain (langchain-rust, llm-chain). There’s a tonne of crates with various levels of investment there, so you probably have to search to find the diamonds in the rough there.
Alternatively, python has a really good TUI framework called Textual, which is worth exploring if you stick more in the python world.
My bad, sorry for my spanglish, I was very sleepy, almost time to bed when I wrote my post. Vinculation means integration
Thanks for all the info, really appreciated, I checked all the links, but for my project, it seems that langchain or pydantic ai are the options to go. So maybe I’ll check Textual, but I’m into Rust also and I want to learn more. Ratatui seems awesome for creating CLIs, but not sure if for example I can handle a terminal application like a entire object that is just getting pass through the python code to make the ratatui intialization in the code. More like in a general sense idea and pseudocode:
gui = ratatui_init()
#Then the rest of the python code script
Do you think something like that is possible in the current state of the art ?
Nevertheless thanks for your help!
EDIT: My idea is that the ratatui_init() should be in the lib.rs , which creates the entire frontend for the python script. Or something very similar to that approach.
No problems on the spanglish. Figured it was something like that.
I don’t really have any python / rust integration experience, so really the best I can say is give it a try and let us know how you fair. It would be great to see what you come up with, but bear in mind that whatever you do you’re going to have to have some sort of message passing / api between the two halves of the app.
You probably can do these kind of things. That will work like C integration with python. You will have to write some kind of api around ratatui and wrap them into extern "C" or something. Also structs that you will use both in python and rust must have #[repr(C)] attribute to be C abi compatible.
The thing is you can define rendering logic in rust and wrap them in some ergonomic api and use python to manage data and call render when needed.
You can also use something like tch-rs crate, because afaik all LLM frameworks are just wrappers around C/C++ libraries.
Thanks @joshka and @liteflow10 for your replies. I will give it a try in the future, since I want the application soon, I would use Textual to make the software more faster. But in my free time I’m going to study more and design the same application using ratatui. You had already gave me the initial guidelines to do that, so thank you for that