feat: NVIDIA NIM LLM-guided analysis - #2
Merged
Conversation
Add opt-in LLM-driven cost analysis powered by NVIDIA NIM, alongside the existing hardcoded rule engines. - lib/nim: vendor-agnostic LLM analysis (rules + system prompt), adapters from Anthropic/OpenAI rows, and deterministic guardrails in mergeLlmFindings (savings clamped to spend, one downgrade per row, no upgrade-as-downgrade, drop zero-savings noise) so a weak model can't emit contradictory or impossible advice. - /api/nim proxy: key from server env (NIM_API_KEY), NIM_MODEL override, NIM_MOCK offline mode, request timeout, GET reports availability. - UI: persisted "Use AI analysis (NVIDIA NIM)" toggle, shown only when the server reports NIM configured. Key never touches the browser. - storage: evict oldest analysis on localStorage quota errors. - tests for guardrails, merge logic, and quota eviction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in LLM-guided cost analysis powered by NVIDIA NIM as an alternative to the hardcoded rule engines. When enabled, an NIM-hosted model reasons over usage instead of fixed thresholds; when off, the existing rule engine runs unchanged.
What's included
lib/nim/— vendor-agnostic LLM analysis: analysis rules + system prompt, adapters from Anthropic/OpenAI rows to a neutral summary, and deterministic guardrails inmergeLlmFindingsthat keep a weak model honest:/api/nimproxy — key read from server envNIM_API_KEY(never sent to the browser);NIM_MODELoverride;NIM_MOCKoffline mode; upstream timeout so slow models fail fast;GETreports whether NIM is configured.localStoragequota errors.Config (deployment)
NIM_API_KEY=nvapi-...— enables the featureNIM_MODEL=...— optional model override (use a valid catalog id)NIM_MOCK=1— optional offline mode for local testingTesting
npm run type-check,npm run lint, andvitestall pass (46 tests)🤖 Generated with Claude Code