Skip to content

Commit

Permalink
chore: Add open-webui to example/llm
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaraj-bh committed Jun 13, 2024
1 parent bd7d185 commit b5fa1ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
35 changes: 32 additions & 3 deletions example/llm/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,38 @@
imports = [
inputs.services-flake.processComposeModules.default
];
services.ollama."ollama1" = {
enable = true;
models = [ "llama2-uncensored" ];
services = {
# Backend service to perform inference on LLM models
ollama."ollama1" = {
enable = true;
# The models are usually huge, downloading them in every project directory can lead to a lot of duplication
dataDir = "$HOME/.services-flake/ollama1";
models = [ "llama2-uncensored" ];
};
# Get ChatGPT like UI, but open-source, with Open WebUI
open-webui."open-webui1" = {
enable = true;
environment = {
OLLAMA_API_BASE_URL = "http://localhost:11434";
WEBUI_AUTH = "False";
};
};
};

# Start the Open WebUI service after the Ollama service has finished initializing and loading the models
settings.processes.open-webui1.depends_on.ollama1-models.condition = "process_completed_successfully";

# Open the browser after the Open WebUI service has started
settings.processes.open-browser = {
command = pkgs.writeShellApplication {
name = "open-browser";
runtimeInputs = lib.optionals pkgs.stdenv.isLinux [ pkgs.xdg-utils ];
text = ''
${ if pkgs.stdenv.isLinux then "xdg-open http://127.0.0.1:1111" else "" }
${ if pkgs.stdenv.isDarwin then "open http://127.0.0.1:1111" else "" }
'';
};
depends_on.open-webui1.condition = "process_healthy";
};
};
};
Expand Down
1 change: 1 addition & 0 deletions nix/open-webui.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ in
success_threshold = 1;
failure_threshold = 5;
};
availability.restart = "on_failure";
};
};
};
Expand Down

0 comments on commit b5fa1ac

Please sign in to comment.