Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/llm: Reintroduce dataDir and models, with explanation in README.md #228

Merged
merged 4 commits into from
Jun 14, 2024
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
15 changes: 15 additions & 0 deletions example/llm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Running local LLM using ollama and open-webui

While `services-flake` is generally used for running services in a *development* project, typically under a source code checkout, you can also write flakes to derive an end-user app which runs a group of services, which then can be run using `nix run` (or installed using `nix profile install`):

```sh
# You can also use `nix profile install` on this URL, and run `services-flake-llm`
nix run github:juspay/services-flake?dir=example/llm
```

## Default configuration & models

`example/llm` runs two processes ollama and open-webui

- The ollama data is stored under `$HOME/.services-flake/ollama`. You can change this path in `flake.nix` by setting the `dataDir` option.
- A single model (`llama2-uncensored`) is automatically downloaded. You can modify this in `flake.nix` as well by setting the `models` option. You can also download models in the open-webui UI.
20 changes: 16 additions & 4 deletions example/llm/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,34 @@
inputs.process-compose-flake.flakeModule
];
perSystem = { self', pkgs, lib, ... }: {
process-compose."default" = pc: {
packages.default = self'.packages.services-flake-llm;

process-compose."services-flake-llm" = pc: {
imports = [
inputs.services-flake.processComposeModules.default
];
services = {
services = let dataDirBase = "$HOME/.services-flake/llm"; in {
# 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. Change here to a
# directory where the Ollama models can be stored and shared across
# projects.
# dataDir = "$HOME/.services-flake/ollama1";
dataDir = "${dataDirBase}/ollama1";

# Define the models to download when our app starts
#
# You can also initialize this to empty list, and download the
# models manually in the UI.
models = [ "llama2-uncensored" ];
};

# Get ChatGPT like UI, but open-source, with Open WebUI
open-webui."open-webui1" = {
enable = true;
dataDir = "${dataDirBase}/open-webui";
environment =
let
inherit (pc.config.services.ollama.ollama1) host port;
Expand All @@ -43,7 +54,8 @@
RAG_EMBEDDING_ENGINE = "ollama";
RAG_EMBEDDING_MODEL = "mxbai-embed-large:latest";
RAG_EMBEDDING_MODEL_AUTO_UPDATE = "True";
RAG_RERANKING_MODEL_AUTO_UPDATE = "True"; };
shivaraj-bh marked this conversation as resolved.
Show resolved Hide resolved
RAG_RERANKING_MODEL_AUTO_UPDATE = "True";
};
};
};

Expand Down
Loading