Skip to content

Commit dfc7dda

Browse files
committed
🖼️ feat: expose provider icons in providers index and NewAPI vendors
- Include `icon` and `lobeIcon` in provider index (written to `dist/api/providers.json`) - Merge overrides before indexing, so icon fields reflect `data/overrides.json` - NewAPI vendors: add `lobeicon` field; set `icon` to `provider.icon || provider.lobeIcon || ''` - Update `buildIndexes(...)` to accept overrides and propagate icon fields Notes: - Backward compatible; existing consumers remain unaffected. - New fields are additive and available after `npm run build`.
1 parent c1a625a commit dfc7dda

File tree

3 files changed

+69
-10
lines changed

3 files changed

+69
-10
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,39 @@ Config: `data/overrides.json`
6262
```json
6363
{
6464
"providers": {
65-
"deepseek": { "displayName": "DeepSeek (custom)" }
65+
"openai": {
66+
"name": "OpenAI (custom)",
67+
"api": "https://api.openai.com",
68+
"doc": "https://platform.openai.com/docs",
69+
"icon": "https://example.com/icons/openai.svg",
70+
"lobeIcon": "OpenAI.Color"
71+
}
6672
},
6773
"models": {
68-
"deepseek/deepseek-reasoner": { "tags": ["reasoning", "math"] }
74+
"openai/gpt-4o": {
75+
"description": "Optimized multimodal model with strong reasoning.",
76+
"tags": ["vision", "tools"],
77+
"limit": { "context": 131072, "output": 8192 },
78+
"modalities": { "input": ["text", "image"], "output": ["text"] },
79+
"reasoning": true,
80+
"tool_call": true,
81+
"attachment": false
82+
}
6983
}
7084
}
7185
```
7286

7387
Deep-merge: original fields preserved unless explicitly overridden.
88+
89+
- Provider-level overrides (e.g., `providers.deepseek.name`, `providers.deepseek.icon`, `providers.deepseek.lobeIcon`, `providers.deepseek.api`, `providers.deepseek.doc`)
90+
- Affects:
91+
- `dist/api/providers.json`
92+
- `dist/api/providers/<provider>.json`
93+
- `dist/api/all.json`
94+
- `dist/api/newapi/vendors.json`
95+
96+
- Model-level overrides (e.g., `models["deepseek/deepseek-reasoner"].description`, `tags`, `limit`, `modalities`, `cost`, `reasoning`, `tool_call`, `attachment`)
97+
- Affects:
98+
- `dist/api/all.json`
99+
- `dist/api/models/<provider>/<model>.json`
100+
- `dist/api/newapi/models.json`

README.zh-CN.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,39 @@ npm run build
6262
```json
6363
{
6464
"providers": {
65-
"deepseek": { "displayName": "DeepSeek(自定义名称)" }
65+
"openai": {
66+
"name": "OpenAI(自定义)",
67+
"api": "https://api.openai.com",
68+
"doc": "https://platform.openai.com/docs",
69+
"icon": "https://example.com/icons/openai.svg",
70+
"lobeIcon": "OpenAI.Color"
71+
}
6672
},
6773
"models": {
68-
"deepseek/deepseek-reasoner": { "tags": ["reasoning", "math"] }
74+
"openai/gpt-4o": {
75+
"description": "面向多模态、具备较强推理能力的优化模型。",
76+
"tags": ["vision", "tools"],
77+
"limit": { "context": 131072, "output": 8192 },
78+
"modalities": { "input": ["text", "image"], "output": ["text"] },
79+
"reasoning": true,
80+
"tool_call": true,
81+
"attachment": false
82+
}
6983
}
7084
}
7185
```
7286

7387
覆写采用“深度合并”,不移除原字段,仅覆盖同名字段或追加对象属性。
88+
89+
- Provider 级覆写(例如:`providers.deepseek.name``providers.deepseek.icon``providers.deepseek.lobeIcon``providers.deepseek.api``providers.deepseek.doc`
90+
- 影响:
91+
- `dist/api/providers.json`
92+
- `dist/api/providers/<provider>.json`
93+
- `dist/api/all.json`
94+
- `dist/api/newapi/vendors.json`
95+
96+
- Model 级覆写(例如:`models["deepseek/deepseek-reasoner"].description``tags``limit``modalities``cost``reasoning``tool_call``attachment`
97+
- 影响:
98+
- `dist/api/all.json`
99+
- `dist/api/models/<provider>/<model>.json`
100+
- `dist/api/newapi/models.json`

scripts/build.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,20 @@ function mapSourceToNormalized(source) {
169169
return { providers };
170170
}
171171

172-
function buildIndexes(normalized) {
172+
function buildIndexes(normalized, overrides) {
173173
const providers = normalized.providers || {};
174174
const providerIndex = [];
175175
const modelIndex = [];
176176
for (const [pid, provider] of Object.entries(providers)) {
177+
const pov = overrides?.providers?.[pid] || {};
178+
const providerEffective = { ...provider, ...pov };
177179
const pInfo = {
178180
id: pid,
179-
name: provider.name || pid,
180-
api: provider.api || null,
181-
doc: provider.doc || null,
181+
name: providerEffective.name || pid,
182+
api: providerEffective.api || null,
183+
doc: providerEffective.doc || null,
184+
icon: providerEffective.icon || null,
185+
lobeIcon: providerEffective.lobeIcon || null,
182186
modelCount: 0,
183187
};
184188
const models = provider.models || {};
@@ -267,7 +271,7 @@ async function main() {
267271
}
268272
}
269273

270-
const { providerIndex, modelIndex } = buildIndexes(normalized);
274+
const { providerIndex, modelIndex } = buildIndexes(normalized, overrides);
271275

272276
const sourceHash = sha256OfObject(source);
273277
const overridesHash = sha256OfObject(overrides);
@@ -520,7 +524,8 @@ function buildNewApiSyncPayload(allModelsData) {
520524
// vendors table fields
521525
name: provider.name || providerId,
522526
description: provider.description || '',
523-
icon: provider.icon || '',
527+
icon: provider.icon || provider.lobeIcon || '',
528+
lobeicon: provider.lobeIcon || '',
524529
status: 1
525530
});
526531

0 commit comments

Comments
 (0)