From 6a446a8383f333304af8856343f1a587b58e875d Mon Sep 17 00:00:00 2001 From: Hyperling Date: Fri, 16 Oct 2026 09:46:46 -0700 Subject: [PATCH] llm, handle max_tokens a little more dynamically, likely only affects the smaller models. --- tasks/workstation/linux/software/llm.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tasks/workstation/linux/software/llm.yml b/tasks/workstation/linux/software/llm.yml index b938fb4..d44b0a5 100644 --- a/tasks/workstation/linux/software/llm.yml +++ b/tasks/workstation/linux/software/llm.yml @@ -832,11 +832,13 @@ {% if llm.model in llm_models.stdout %} {% if "chat" in llm.purpose %} - [providers.models.ollama.{{ llm.provider }}] + [providers.models.ollama.{{ llm.provider }}_{{ 'CODE' if "code" in llm.purpose else 'CHAT' + }}{{ '' if llm.model in llm_models.stdout else '-MISSING' + }}] model = "{{ llm.model }}" timeout_secs = 3600 # 1 hour, default is 120 (2 minutes), issue happens between 5 and 6 minutes though. context_window = {{ [llm.context] | min | int }} - max_tokens = {{ [(llm.context / 8)] | min | int }} + max_tokens = {{ [(llm.context / 8), 16000] | min | int }} {% endif %} {% endif %} @@ -865,19 +867,22 @@ {% if llm.model in llm_models.stdout %} {% if "code" in llm.purpose %} - - name: {{ llm.provider }}_CHAT + - name: {{ llm.provider }}_{{ 'CODE' if "code" in llm.purpose else 'CHAT' + }}{{ '' if llm.model in llm_models.stdout else '-MISSING' + }} provider: ollama model: {{ llm.model }} defaultCompletionOptions: contextLength: {{ [llm.context] | min | int }} - maxTokens: {{ [16000] | min | int }} + maxTokens: {{ [(llm.context / 8), 16000] | min | int }} - - name: {{ llm.provider }}_AUTO + - name: {{ llm.provider }}_AUTO{{ '' if llm.model in llm_models.stdout else '-MISSING' + }} provider: ollama model: {{ llm.model }} defaultCompletionOptions: contextLength: {{ [llm.context] | min | int }} - maxTokens: {{ [4000] | min | int }} + maxTokens: {{ [(llm.context / 8), 4000] | min | int }} roles: - autocomplete @@ -918,10 +923,10 @@ }, "timeout": 600000, "streamIdleTimeoutMs": 600000, - "contextWindowSize": {{ llm.context }}, + "contextWindowSize": {{ [llm.context] | min | int }}, "maxRetries": 3, "samplingParams": { - "max_tokens": 8000 + "max_tokens": {{ [(llm.context / 8), 16000] | min | int }} ,"temperature": 0.7 } }