Files
dotfiles/home-modules/ollama.nix
Lennart J. Kurzweg (Nx2) d2d1ce7830 overlays refactor
2025-06-17 19:48:31 +02:00

39 lines
817 B
Nix

{ pkgs, ... }@all: with all;
{
home.packages = with pkgs; [
ollama
(writers.writePython3Bin "ooo" {
libraries = [ pkgs.python3Packages.ollama ];
flakeIgnore = [ "E501" "E305" "E701" "E704" "E302" "E114" "F841" "E121" ];
} /* python */ ''
import sys
import ollama
if len(sys.argv) < 2:
print("Usage: ./ooo.py <system_message>")
sys.exit(1)
system_message = sys.argv[1]
input_text = sys.stdin.read()
try:
response = ollama.chat(model='gemma3:4b', messages=[
{
'role': 'system',
'content': system_message,
},
{
'role': 'user',
'content': input_text,
},
])
print(response['message']['content'])
sys.exit(0)
except Exception as e:
print(f"An error occurred: {e}", file=sys.stderr)
sys.exit(1)
'')
];
}