fix(number-fields): избегаем потери точности длинных чисел

- number-поля теперь рендерятся как text + inputMode=numeric,
  чтобы браузер не округлял значения через input type=number
- пробелы при вставке в number-поля удаляются
- бэкенд нормализует значения number-полей в строку перед сохранением
- добавлен хелпер normalizeFieldValueForStorage

Closes: искажение расчётного счёта и других длинных числовых полей
This commit is contained in:
2026-07-07 21:03:40 +03:00
commit 1f5ecb6da4
1089 changed files with 237546 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
/**
* Ollama runtime configuration helpers.
*
* Reads env vars and CPU count to produce sensible defaults
* for num_thread / num_ctx so that Ollama uses the server efficiently.
*/
import { cpus } from "os";
/** CPU cores visible to Node (host cores when no Docker limit is set). */
function detectCpuCount(): number {
try {
return cpus().length;
} catch {
return 1;
}
}
/**
* Number of threads Ollama should use for inference.
* Priority:
* 1. OLLAMA_NUM_THREAD env var
* 2. cpus().length (leave 1 core for OS / other containers when > 1)
*/
export function getOllamaNumThread(): number {
if (process.env.OLLAMA_NUM_THREAD) {
const parsed = parseInt(process.env.OLLAMA_NUM_THREAD, 10);
if (!Number.isNaN(parsed) && parsed > 0) {
return parsed;
}
}
const count = detectCpuCount();
// Leave one core for the OS / DB / app when we have > 1 core
return Math.max(1, count > 1 ? count - 1 : count);
}
/**
* Context window size for Ollama models.
* Priority:
* 1. OLLAMA_NUM_CTX env var
* 2. Default 2048 (safe for CPU-only setups)
*/
export function getOllamaNumCtx(): number {
if (process.env.OLLAMA_NUM_CTX) {
const parsed = parseInt(process.env.OLLAMA_NUM_CTX, 10);
if (!Number.isNaN(parsed) && parsed >= 512) {
return parsed;
}
}
return 2048;
}