dynamic ollama aichat

This commit is contained in:
jmarkin 2025-11-14 20:10:09 +03:00
parent 2ca1d09e88
commit 7a8857698a
2 changed files with 86 additions and 92 deletions

View file

@ -130,11 +130,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1762810396,
"narHash": "sha256-dxFVgQPG+R72dkhXTtqUm7KpxElw3u6E+YlQ2WaDgt8=",
"lastModified": 1762980239,
"narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "0bdadb1b265fb4143a75bd1ec7d8c915898a9923",
"rev": "52a2caecc898d0b46b2b905f058ccc5081f842da",
"type": "github"
},
"original": {
@ -452,11 +452,11 @@
"yaml-nvim": "yaml-nvim"
},
"locked": {
"lastModified": 1762972605,
"narHash": "sha256-ItH9lF0QEb7Js3qt4eDnBDbJjqz6Ic0LINkp5/Sv9k4=",
"lastModified": 1763119940,
"narHash": "sha256-v35923ZjBiJ69ORf5R/1XXPbSfLbJ7GSXgLXciMAgvI=",
"ref": "refs/heads/master",
"rev": "6373116d06f2718cc92c9c2ddc4f0f86c3530f77",
"revCount": 50,
"rev": "5a39ef069496e2a89be44b2ff27647f2ee421243",
"revCount": 51,
"type": "git",
"url": "https://git.jmarkin.ru/jmarkin/nvim-nix"
},
@ -492,11 +492,11 @@
]
},
"locked": {
"lastModified": 1762905877,
"narHash": "sha256-Leao4Ts2loeMfslCEC2xjy6UH7H7C7g2u6yX/HqWYbM=",
"lastModified": 1763078664,
"narHash": "sha256-HDuT9S50/3+2blDIL4Y5qX8g5bA5FtpzP9lyagmyNq4=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "a8d1fa088164a7f4df2161a86d18d91b7100064c",
"rev": "994eb1828abe40f256e27ff38663b4f3f819d4cb",
"type": "github"
},
"original": {
@ -508,11 +508,11 @@
"neovim-src": {
"flake": false,
"locked": {
"lastModified": 1762904335,
"narHash": "sha256-52qh41MWguVgvnmvFvBAoU76x1zDO88LYc0l86aMaGo=",
"lastModified": 1763078375,
"narHash": "sha256-oGwmSPl+FA0y2uPEGkkavr5sxLkpHR6+Cio8eZ8OtPo=",
"owner": "neovim",
"repo": "neovim",
"rev": "97cb0d55717f0b9ffe0748d4cd220217abc51a63",
"rev": "d017f3c9a0b745e0c57feb8c92dcc852948f7301",
"type": "github"
},
"original": {
@ -616,11 +616,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1762604901,
"narHash": "sha256-Pr2jpryIaQr9Yx8p6QssS03wqB6UifnnLr3HJw9veDw=",
"lastModified": 1762943920,
"narHash": "sha256-ITeH8GBpQTw9457ICZBddQEBjlXMmilML067q0e6vqY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f6b44b2401525650256b977063dbcf830f762369",
"rev": "91c9a64ce2a84e648d0cf9671274bb9c2fb9ba60",
"type": "github"
},
"original": {
@ -737,11 +737,11 @@
"smart-splits-nvim": {
"flake": false,
"locked": {
"lastModified": 1762958613,
"narHash": "sha256-2YeMg76UeLQd2XtLJQnFbaaRTReMowC5o8k5KEyYwUk=",
"lastModified": 1763042397,
"narHash": "sha256-V81DzQUHgMrpY9BVDUJLv5oegoqZXV1pzzL74rqsx4g=",
"owner": "mrjones2014",
"repo": "smart-splits.nvim",
"rev": "63b17752f7f1d8cd19079953fb7450ecca1e546e",
"rev": "79d78a0a3fdf1239eaf444975976e0b8de981e2e",
"type": "github"
},
"original": {

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:
let
yek = pkgs.rustPlatform.buildRustPackage rec {
pname = "yek";
@ -25,85 +25,79 @@ let
in
rec {
home.packages = with pkgs; [
aichat
poppler-utils
pandoc
yek
];
programs.aichat.enable = true;
programs.aichat.settings = {
model = "ollama:orieg/gemma3-tools:4b";
stream = true;
save = true;
keybindings = "vi";
editor = "nvim";
wrap = "no";
wrap_code = false;
function_calling = true;
save_session = null; # or false, depending on the option type
compress_threshold = 9000;
summarize_prompt = "Summarize the discussion briefly in 1000 words or less to use as a prompt for future context.";
summary_prompt = "This is a summary of the chat history as a recap: ";
rag_embedding_model = "ollama:nomic-embed-text:latest";
rag_top_k = 5;
rag_chunk_size = 256;
rag_chunk_overlap = 200;
# Document loaders
document_loaders = {
pdf = "pdftotext $1 -";
docx = "pandoc --to plain $1";
git = "sh -c \"yek $1 --json | jq '[.[] | { path: .filename, contents: .content }]'\"";
};
# Clients configuration
clients = [
{
type = "openai-compatible";
name = "ollama";
api_base = "${config.home.sessionVariables.OLLAMA_URL}/v1";
models = [
{
name = "orieg/gemma3-tools:4b";
max_input_tokens = 128000;
supports_function_calling = true;
supports_vision = true;
}
{
name = "gpt-oss-safeguard:20b";
max_input_tokens = 8128;
supports_function_calling = true;
supports_vision = true;
}
{
name = "danielsheep/Qwen3-Coder-30B-A3B-Instruct-1M-Unsloth:UD-IQ3_XXS";
max_input_tokens = 8128;
supports_function_calling = true;
supports_vision = true;
}
{
name = "nomic-embed-text:latest";
type = "embedding";
default_chunk_size = 1000;
max_batch_size = 50;
}
];
}
];
};
home.sessionVariables = {
OLLAMA_URL = lib.mkDefault "http://192.168.88.15:11434";
};
home.file.".config/aichat/config.yaml".text = /*yaml*/''
model: ollama:orieg/gemma3-tools:4b # Specify the LLM to use
stream: true # Controls whether to use the stream-style API.
save: true # Indicates whether to persist the message
keybindings: vi # Choose keybinding style (emacs, vi)
editor: nvim # Specifies the command used to edit input buffer or session. (e.g. vim, emacs, nano).
wrap: no # Controls text wrapping (no, auto, <max-width>)
wrap_code: false # Enables or disables wrapping of code blocks
function_calling: true # Enables or disables function calling (Globally).
rag_embedding_model: ollama:nomic-embed-text:latest # Specifies the embedding model used for context retrieval
document_loaders:
# You can add custom loaders using the following syntax:
# <file-extension>: <command-to-load-the-file>
# Note: Use `$1` for input file and `$2` for output file. If `$2` is omitted, use stdout as output.
pdf: 'pdftotext $1 -' # Load .pdf file, see https://poppler.freedesktop.org to set up pdftotext
docx: 'pandoc --to plain $1' # Load .docx file, see https://pandoc.org to set up pandoc
git: >
sh -c "yek $1 --json | jq '[.[] | { path: .filename, contents: .content }]'"
# ---- clients ----
clients:
# All clients have the following configuration:
# - type: xxxx
# name: xxxx # Only use it to distinguish clients with the same client type. Optional
# models:
# - name: xxxx # Chat model
# max_input_tokens: 100000
# supports_vision: true
# supports_function_calling: true
# - name: xxxx # Embedding model
# type: embedding
# default_chunk_size: 1500
# max_batch_size: 100
# - name: xxxx # Reranker model
# type: reranker
# patch: # Patch api
# chat_completions: # Api type, possible values: chat_completions, embeddings, and rerank
# <regex>: # The regex to match model names, e.g. '.*' 'gpt-4o' 'gpt-4o|gpt-4-.*'
# url: "" # Patch request url
# body: # Patch request body
# <json>
# headers: # Patch request headers
# <key>: <value>
# extra:
# proxy: socks5://127.0.0.1:1080 # Set proxy
# connect_timeout: 10 # Set timeout in seconds for connect to api
# See https://platform.openai.com/docs/quickstart
- type: openai-compatible
name: ollama
api_base: ${home.sessionVariables.OLLAMA_URL.content}/v1
models:
- name: orieg/gemma3-tools:4b
max_input_tokens: 128000
supports_function_calling: true
supports_vision: true
- name: gpt-oss-safeguard:20b
max_input_tokens: 8128
supports_function_calling: true
supports_vision: true
- name: danielsheep/Qwen3-Coder-30B-A3B-Instruct-1M-Unsloth:UD-IQ3_XXS
max_input_tokens: 8128
supports_function_calling: true
supports_vision: true
- name: nomic-embed-text:latest
type: embedding
default_chunk_size: 1000
max_batch_size: 50
'';
}