Skip to content

Commit

Permalink
Add Falcon LLM
Browse files Browse the repository at this point in the history
Signed-off-by: Humaid Alqasimi <[email protected]>
  • Loading branch information
humaidq-tii committed Sep 30, 2024
1 parent 1733e08 commit 16f3322
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 3 deletions.
117 changes: 117 additions & 0 deletions falcon-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions modules/common/services/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ in
icon = "${pkgs.icon-pack}/bluetooth-48.svg";
}

{
name = "Falcon AI";
path = "${pkgs.alpaca}/bin/alpaca";
icon = ../../../falcon-icon.svg;
}

{
name = "Shutdown";
description = "Shutdown System";
Expand Down
2 changes: 2 additions & 0 deletions modules/reference/profiles/laptop-x86.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ in
networking.enable = true;
};

reference.services.ollama = true;

# UI applications
# TODO fix this when defining desktop and apps
profiles = {
Expand Down
8 changes: 5 additions & 3 deletions modules/reference/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ in
imports = [
./dendrite-pinecone/dendrite-pinecone.nix
./dendrite-pinecone/dendrite-config.nix
./ollama/ollama.nix
];
options.ghaf.reference.services = {
enable = mkEnableOption "Enable the Ghaf reference services";
dendrite = mkEnableOption "Enable the dendrite-pinecone service";
enable = mkEnableOption "Ghaf reference services";
dendrite = mkEnableOption "dendrite-pinecone service";
ollama = mkEnableOption "ollama service";
};
config = mkIf cfg.enable {
ghaf.reference.services = {
ghaf.reference.services = mkIf cfg.enable {
dendrite-pinecone.enable = mkForce (cfg.dendrite && isNetVM);
};
};
Expand Down
22 changes: 22 additions & 0 deletions modules/reference/services/ollama/ollama.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{ config, lib, ... }:
let
cfg = config.ghaf.reference.services;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.ollama) {
services.ollama = {
enable = true;
openFirewall = true;
host = "0.0.0.0";
loadModels = [ "falcon2" ];
};
systemd.services.ollama.serviceConfig = {
TimeoutStartSec = "5h";
Restart = "always";
RestartSec = "5s";
};
};
}
71 changes: 71 additions & 0 deletions overlays/custom-packages/alpaca/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
{ prev, final }:
let
inherit (prev) python3Packages fetchFromGitHub lib;
in
python3Packages.buildPythonApplication rec {
pname = "alpaca";
version = "2.0.5";
pyproject = false; # Built with meson

src = fetchFromGitHub {
owner = "Jeffser";
repo = "Alpaca";
rev = "refs/tags/${version}";
hash = "sha256-BLLcU2GESyHGFJJicE42V3nMFf/YfnYsXcAOPIHuCAg=";
};

nativeBuildInputs = with prev; [
appstream
meson
ninja
pkg-config
gobject-introspection
wrapGAppsHook4
desktop-file-utils
];

buildInputs = with prev; [
libadwaita
gtksourceview5
];

dependencies = with python3Packages; [
pygobject3
requests
pillow
pypdf
pytube
html2text
];

dontWrapGApps = true;

makeWrapperArgs = [
"\${gappsWrapperArgs[@]}"
"--prefix PATH : ${lib.makeBinPath [ prev.xdg-utils final.ollama ]}"
# Declared but not used in src/window.py, for later reference
# https://github.com/flatpak/flatpak/issues/3229
"--set FLATPAK_DEST ${placeholder "out"}"
];

meta = {
description = "Ollama client made with GTK4 and Adwaita";
longDescription = ''
To run Alpaca with GPU acceleration enabled, simply override it:
```nix
pkgs.alpaca.override {
ollama = pkgs.ollama-cuda;
}
```
Or using `pkgs.ollama-rocm` for AMD GPUs.
'';
homepage = "https://jeffser.com/alpaca";
license = lib.licenses.gpl3Plus;
mainProgram = "alpaca";
maintainers = with lib.maintainers; [ aleksana ];
platforms = lib.platforms.linux;
};
}
2 changes: 2 additions & 0 deletions overlays/custom-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
gtklock = import ./gtklock { inherit prev; };
hardware-scan = final.callPackage ../../packages/hardware-scan { };
pulseaudio-ghaf = import ./pulseaudio { inherit prev; };
ollama = import ./ollama { inherit prev; };
alpaca = import ./alpaca { inherit final prev; };
})
15 changes: 15 additions & 0 deletions overlays/custom-packages/ollama/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
# This overlay customizes labwc - see comments for details
#
{ prev }:
prev.ollama.overrideAttrs {
src = prev.fetchFromGitHub {
owner = "ollama";
repo = "ollama";
rev = "v0.3.1";
hash = "sha256-ctz9xh1wisG0YUxglygKHIvU9bMgMLkGqDoknb8qSAU=";
fetchSubmodules = true;
};
}
1 change: 1 addition & 0 deletions targets/generic-x86_64/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ let
self.nixosModules.microvm
self.nixosModules.hw-x86_64-generic
self.nixosModules.reference-programs
self.nixosModules.reference-services

{
ghaf = {
Expand Down

0 comments on commit 16f3322

Please sign in to comment.