OLLMrpc


Description:

Binary RPC client and wire types shared by apps and ollmfilesd.

The OLLMrpc namespace is the client library for talking to ollmfilesd over a Unix socket (or stdio/TCP), and for calling HTTPS JSON APIs with the same Request / Response shape. Client owns the channel. Request carries method, positional args via args, and optional result_type. Bin serializes Bin.Serializable GObjects on the wire. Transport is the daemon listen/connection side. Live is opt-in live GObject handles (ref, unref, subscribe).

Architecture Benefits

  • Positional args: D-Bus signature packing via args, not ad-hoc JSON bags
  • One client: Unix socket for ollmfilesd, HTTPS URL for Hub-style APIs
  • Bin codec: compact wire with JIT property keys (Bin.Stream)
  • Shared types: same Request/Response on client and daemon

Usage Examples

ollmfilesd (Unix socket)

OLLMrpc.Daemon.rpc_register();
var rpc = new OLLMrpc.Client(
GLib.Path.build_filename(
GLib.Environment.get_user_data_dir(), "ollmchat"),
"ollmfilesd.pid",
"ollmfilesd.sock"
);
if (!yield rpc.connect(new OLLMrpc.Request() {
method = "RPC-Daemon.hello",
args = OLLMrpc.args("is", 1, "my-app")
}, new OLLMrpc.ClientBoot())) {
GLib.error("%s", rpc.connect_error);
}
var resp = yield rpc.call(new OLLMrpc.Request() {
method = "ProjectManager.rpc_load_projects_from_db"
});

HTTPS JSON (e.g. Hugging Face Hub)

OLLMhf.rpc_register();
var rpc = new OLLMrpc.Client("", "", "https://huggingface.co");
yield rpc.connect(new OLLMrpc.Request());
var resp = yield rpc.call(new OLLMrpc.Request() {
method = "/api/models",
args = OLLMrpc.args("o", new OLLMhf.Param.Search() {
search = "llama",
filter = "gguf",
limit = 10
}),
result_type = typeof(OLLMhf.ModelArray)
});

Best Practices

  1. Registration: call each wire type's rpc_register() before connect

    2. Args: pack with args onto Request.args, not raw maps

    3. Results: set result_type when the HTTP path should decode to a GType

    4. Errors: check Response.error after every call

    5. Bin round-trips: see Bin and docs/bin-rpc-protocol.md

Content:

Namespaces:

Interfaces:

Classes:

Error domains:

Functions: