Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
7 changes: 7 additions & 0 deletions scripts/server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

# Add additional command line arguments as configured
SERVER_OPTS=()
read -r -a SERVER_OPTS <<< "$(snapctl get server-opts)";
exec "${SNAP}"/bin/cli-wrapper server "${SERVER_OPTS[@]}"
5 changes: 5 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ esac
if [ -z "$backend" ]; then
snapctl set backend=auto
fi

# Set the default value for server-opts
if [ -z "$(snapctl get server-opts)" ]; then
snapctl set server-opts=""
fi
29 changes: 26 additions & 3 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ description: |
or override it per invocation with the env var:

LLAMA_CPP_BACKEND=cpu llama-cpp cli ...

The llama.cpp web server can also be run using the llama-cpp.server app. This
is disabled by default but can be enabled by running:

snap start --enable llama-cpp.server

By default, no additional arguments are passed to the server, meaning it will
listen on the default port and address. Arguments can be specified by setting
the server-opts configuration value, e.g.:

snap set llama-cpp server-opts="--host 0.0.0.0"

Afterwards, the server must be restarted for the new arguments to take effect:

snap restart llama-cpp.server
license: MIT
source-code:
- https://github.com/talhaHavadar/snap-llama.cpp
Expand Down Expand Up @@ -88,10 +103,10 @@ components:
apps:
llama-cpp:
command: bin/cli-wrapper
extensions:
extensions: &extensions
# Automatically binds host Vulkan/OpenGL maps
- gpu
plugs:
plugs: &plugs
- home
- network
- network-bind
Expand All @@ -106,15 +121,23 @@ apps:
# llama.cpp pins worker threads with sched_setaffinity. Without this
# application fails to init.
- process-control
server:
command: bin/server-wrapper
daemon: simple
install-mode: disable
extensions: *extensions
plugs: *plugs
parts:
# --- Wrapper script ------------------------------------------------------
cli:
plugin: dump
source: .
source: scripts
stage:
- bin/cli-wrapper
- bin/server-wrapper
organize:
cli.sh: bin/cli-wrapper
server.sh: bin/server-wrapper
# --- ggml: CPU + loader libs, lives in the main snap --------------------
# Builds llama.cpp's bundled ggml/ subdirectory standalone with the
# backend-dl loader enabled and every CPU variant emitted as its own .so.
Expand Down
Loading