feat: connect ledger / refactor#48
Merged
Merged
Conversation
Greptile SummaryThis PR adds per-model pricing data to the Redis cache. When Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant DM as DataManager (fetch.ts)
participant API as models.dev API
participant S as Schema (modelsdev.ts)
participant R as Redis (model_cost.ts)
DM->>API: GET /api.json
API-->>DM: JSON payload
DM->>S: decodeUnknown(ProviderModelMapSchema)(json)
S-->>DM: provider → string[] map
DM->>R: bulkSetModelsForProvider(supported)
DM->>S: decodeUnknown(ProviderModelToCostSchema)(json)
S-->>DM: provider → [{model, input, output}][]
DM->>DM: reduce to {provider/model → {input, output}}
DM->>R: bulkSetProviderModelCost(supportedCost)
R->>R: setCostForModel × N (concurrency=5)
Note over R: PREFIX = "enfinyte:model_to_cost:"
Reviews (1): Last reviewed commit: "feat: add model cost to redis" | Re-trigger Greptile |
Record every LLM request as a ledger transaction with resolution latency, category, token usage, cost, timing (ttft + total latency), and error info. Extends resolver return type to thread category through all resolution paths and exposes getCostForModel on ResolverService for cost lookups from Redis.
a2da0fb to
08c82bf
Compare
…uced duplication - Rename 7 absurdly long filenames in api_platform/services/ai (e.g., responseFieldsToAISDKGenerateTextCallSettingsAdapters.ts → adapters.ts) - Extract RequestParams type to replace 5-param function signatures - Extract prepareCallOptions, tryProviders, resolveProviders shared helpers - Extract buildBaseResponse to eliminate 3x duplicated ResponseResource defaults - Create provider-registry.ts to unify duplicated provider switches - Move ProviderModelPair, IntentPair, Intent domain types to common package - Extract VerifyApiKeyResult to common for cross-service contract - Extract classifyWithLLM generic helper from near-identical getCategory/getPolicy - Extract assembleUserContext from backend apikey verifyKey - Centralize Redis key prefixes in resolver/redis/consts.ts - Simplify resolver dispatch from Match pattern to simple tag check - Remove verbose logging from parsers (error types carry the context) - Remove dead code: classification-cache.ts, MOCK_* constants, console.logs, void outputFormat, duplicate validation, commented-out service, stale TODO - Fix @ts-expect-error in data_manager/fetch.ts with proper typing - Fix .ts import extension in match_models.ts - Fix misleading error messages in AI service fallback paths Net result: -460 lines, 0 type errors, 0 test regressions (156 pass, 7 pre-existing fail)
vidurkhanal
approved these changes
Apr 4, 2026
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.
No description provided.