refresh-json-data
Refresh token estimator and model pricing JSON files with latest data from AI model providers
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Refresh JSON Data Skill
This skill helps you update the token estimation ratios and model pricing data in the Copilot Token Tracker extension.
Overview
The extension uses two JSON data files that need periodic updates:
- tokenEstimators.json - Character-to-token ratio estimators for AI models
- modelPricing.json - Pricing information per million tokens for various AI models
These files are located in src/ directory and are bundled into the extension at build time.
When to Use This Skill
Use this skill when you need to:
- Add support for new AI models
- Update token estimation ratios based on new benchmarks
- Refresh pricing information from provider APIs
- Keep model data current with latest releases
Prerequisites
Before updating these files, ensure you have:
- Access to official pricing documentation from AI providers
- Token estimation benchmarks or documentation
- The repository cloned locally
- Node.js and npm installed
Step 1: Update tokenEstimators.json
Location
src/tokenEstimators.json
Structure
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Character-to-token ratio estimators for different AI models.",
"estimators": {
"model-name": 0.25
}
}
Update Process
-
Research token ratios for new or updated models:
- Typical ratios range from 0.24-0.25 (roughly 4 characters per token)
- GPT models typically use 0.25
- Claude models typically use 0.24
- Check model documentation or use tokenizer tools to verify
-
Add or update entries in the
estimatorsobject:"new-model-name": 0.25 -
Common model families and their ratios:
- GPT-4, GPT-5, GPT-O models: 0.25
- Claude models: 0.24
- Gemini models: 0.25
- Other models: verify with provider documentation
-
Validation:
- Ensure JSON syntax is valid
- Keep ratio values between 0.20 and 0.30
- Use consistent formatting
Step 2: Update modelPricing.json
Location
src/modelPricing.json
Structure
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Model pricing data - costs per million tokens",
"metadata": {
"lastUpdated": "YYYY-MM-DD",
"sources": [
{
"name": "Provider Name",
"url": "https://pricing-url",
"retrievedDate": "YYYY-MM-DD"
}
],
"disclaimer": "..."
},
"pricing": {
"model-name": {
"inputCostPerMillion": 1.25,
"outputCostPerMillion": 10.0,
"category": "Model category"
}
}
}
Update Process
-
Check official pricing pages:
- OpenAI: https://openai.com/api/pricing/
- Anthropic: https://www.anthropic.com/pricing
- Google Gemini: https://ai.google.dev/pricing
- GitHub Copilot Models: https://docs.github.com/en/copilot/reference/ai-models/supported-models
-
Update pricing entries in the
pricingobject:"model-name": { "inputCostPerMillion": 1.25, "outputCostPerMillion": 10.0, "category": "Provider models" } -
Update metadata:
- Set
metadata.lastUpdatedto current date (YYYY-MM-DD format) - Add or update source URLs and retrieval dates
- Keep the disclaimer intact
- Set
-
Pricing guidelines:
- Costs are per million tokens
- Input costs are typically lower than output costs
- Group models by category (e.g., "GPT-4 models", "Claude models")
- Verify pricing is in USD
-
Validation:
- Ensure JSON syntax is valid
- Verify pricing values are positive numbers
- Check that all required fields are present
Step 3: Build and Test
After updating the JSON files:
-
Validate JSON syntax:
# Check JSON is valid node -e "require('./src/tokenEstimators.json')" node -e "require('./src/modelPricing.json')" -
Rebuild the extension:
npm run compile -
Test in VS Code:
- Press F5 to launch Extension Development Host
- Check that the extension loads without errors
- Verify token tracking still works correctly
- Review the details panel to confirm pricing calculations
-
Review changes:
git diff src/tokenEstimators.json git diff src/modelPricing.json
Step 4: Commit Changes
-
Stage the files:
git add src/tokenEstimators.json src/modelPricing.json -
Commit with descriptive message:
git commit -m "Update model pricing and token estimators - Updated pricing for [model names] - Added support for [new models] - Refreshed data from provider APIs as of [date]" -
Push and create PR:
git push origin your-branch-name
Important Notes
-
Bundled at build time: These JSON files are bundled into the extension during compilation via
esbuild.js -
Rebuild required: Always run
npm run compileafter changes - Pricing disclaimer: GitHub Copilot pricing may differ from direct API usage
- Estimation nature: Token counts are estimates based on character ratios
-
Documentation: See
src/README.mdfor additional details
Reference Resources
- VS Code extension development: https://code.visualstudio.com/api
- Token estimation methodology: Character-to-token ratios based on model tokenizers
- Cost calculation: Uses 50/50 split between input and output tokens for estimates
Troubleshooting
JSON validation errors:
- Use a JSON validator or VS Code's built-in JSON validation
- Check for missing commas, quotes, or brackets
Build failures after update:
- Verify JSON syntax is correct
- Ensure all required fields are present
- Check that numeric values are not strings
Extension not loading updated data:
- Confirm you ran
npm run compile - Reload the Extension Development Host (Cmd/Ctrl+R)
- Check the output console for errors
Example Update Workflow
# 1. Update the JSON files with new data
code src/tokenEstimators.json
code src/modelPricing.json
# 2. Validate JSON syntax
node -e "require('./src/tokenEstimators.json')" && echo "tokenEstimators.json: OK"
node -e "require('./src/modelPricing.json')" && echo "modelPricing.json: OK"
# 3. Rebuild the extension
npm run compile
# 4. Test in VS Code
# Press F5 to launch Extension Development Host
# 5. Commit changes
git add src/tokenEstimators.json src/modelPricing.json
git commit -m "Update model pricing data for 2026-01"
git push origin update-model-data
Additional Context
The extension reads these files at compile time via:
import tokenEstimatorsData from './tokenEstimators.json';
import modelPricingData from './modelPricing.json';
The data is then used in the CopilotTokenTracker class:
-
tokenEstimators- Used for token estimation from character counts -
modelPricing- Used for cost calculations in the details panel
Both files must maintain their structure to ensure the extension compiles and runs correctly.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-02-04
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!