barrel_embed_port_server (barrel_embed v2.3.1)
View SourceAsync Python port server with request multiplexing
A gen_server that manages communication with a Python embedding server. Supports concurrent requests by tracking request IDs and routing responses back to the correct callers.
Usage
%% Start the server
{ok, Server} = barrel_embed_port_server:start_link(Python, Args, Opts).
%% Make concurrent embedding requests
spawn(fun() -> barrel_embed_port_server:embed_batch(Server, Texts1, 60000) end).
spawn(fun() -> barrel_embed_port_server:embed_batch(Server, Texts2, 60000) end).
%% Stop when done
barrel_embed_port_server:stop(Server).Request Multiplexing
Multiple Erlang processes can call embed_batch/3 concurrently. Each request is assigned a unique ID and sent to Python. The Python server includes the ID in its response, allowing this gen_server to route responses to the correct waiting callers.
Summary
Functions
Generate embeddings for texts.
Generate embeddings for images (base64 encoded).
Generate multi-vector embeddings.
Generate sparse embeddings.
Get model info.
Start the port server. Args are passed to python -m barrel_embed.
Stop the server and close the port.
Functions
Generate embeddings for texts.
Generate embeddings for images (base64 encoded).
Generate multi-vector embeddings.
Generate sparse embeddings.
Get model info.
-spec start_link(string(), [string()], proplists:proplist()) -> {ok, pid()} | {error, term()}.
Start the port server. Args are passed to python -m barrel_embed.
-spec stop(pid()) -> ok.
Stop the server and close the port.