Bin RPC client for ollmfilesd, compositor sockets, and HTTPS JSON APIs.
Socket mode exchanges bin Request/Response
pairs. Pass a ClientBoot to
connect to spawn ollmfilesd; omit it to attach to an already-listening socket. HTTP mode (socket_name is an https URL, empty
data_dir) sends JSON REST calls — used by libochf for Hugging Face Hub. Register wire types before
connect.
Basic Usage
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
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)
});
HTTPS RPC (ollmfilesd gate)
var http = new OLLMrpc.Transport.HttpClient("https://host:8443") {
bin_body = true,
tls_certificate = leaf.certificate,
tls_database = leaf.trust
};
var rpc = new OLLMrpc.Client("", "", "https://host:8443") {
http = http
};
if (!yield rpc.connect(new OLLMrpc.Request() {
method = "RPC-Daemon.hello",
args = OLLMrpc.args("is", 1, "ollmchat")
})) {
GLib.error("%s", rpc.connect_error);
}
See also:
Request, Response