mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-12 06:55:08 -05:00
This commit fixes the Ollama server /api/chat endpoint which was ignoring the client-provided num_ctx parameter and global DEFAULT_MODEL_CONTEXT_LENGTH, always using a hardcoded value of 2048 tokens. - Add parseOllamaNumCtx() function in ollama.go with type-safe extraction supporting 6 numeric types (float64, float32, int, int64, json.Number, string) - Extract num_ctx from client request options in ollamaChat() - Add ModelContextLength field to ChatRequest struct in chat.go - Replace hardcoded 2048 with request.ModelContextLength in GetChatter() call - Platform-aware integer overflow protection for 32-bit systems - DoS protection via 1,000,000 token maximum limit - Long string truncation in error messages (50 char limit) - Sanitized error messages (no internal stdlib details exposed) - Missing/null num_ctx returns (0, nil) to trigger existing default fallback - Zero API contract changes - Invalid values return 400 Bad Request with clear error messages - All existing tests pass - Compilation successful with no errors or warnings Fixes #1942