Feat/custom token rates for endpoints #6086
Draft
+167
−9
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
Closes: #1633
This pull request introduces custom token and cache override functionality for different models, updates the configuration loading process, and adds type definitions for token rates in the
api
andpackages/data-provider
directories. The most important changes include adding new functions to set custom overrides, modifying the cache multiplier retrieval logic, and updating the configuration schema.Custom override functionality:
api/models/tx.js
: AddedsetCustomTokenOverrides
andsetCustomCacheOverrides
functions to allow overriding default token and cache multipliers for specific models. [1] [2]Cache multiplier retrieval logic:
api/models/tx.js
: Updated thegetCacheMultiplier
function to check for custom cache overrides before falling back to default values.Configuration loading:
api/server/services/AppService.js
: AddedloadTokenRatesConfig
to the configuration loading process to handle custom token rates. [1] [2]api/server/services/Config/loadTokenRatesConfig.js
: Implemented theloadTokenRatesConfig
function to merge user and default token rates and apply custom overrides.Type definitions:
packages/data-provider/src/config.ts
: Added type definitions for token rates (TTokenCost
andTModelTokenRates
) and updated the configuration schema to include token rates. [1] [2]Change Type
Please delete any irrelevant options.
Testing
Please describe your test process and include instructions so that we can reproduce your test. If there are any important variables for your testing configuration, list them here.
Test Configuration:
Checklist
Please delete any irrelevant options.