Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(model-runtime): map PPIO and Qiniu upstream model metadata onto model cards (#18484)

YuTengjingeee2a005410f
diff --git a/packages/model-runtime/src/providers/ppio/__snapshots__/index.test.ts.snap b/packages/model-runtime/src/providers/ppio/__snapshots__/index.test.ts.snap
index aee1b20b3eb..e2de95de804 100644
--- a/packages/model-runtime/src/providers/ppio/__snapshots__/index.test.ts.snap
+++ b/packages/model-runtime/src/providers/ppio/__snapshots__/index.test.ts.snap
@@ -11,6 +11,7 @@ exports[`PPIO > models > should get models 1`] = `
"id": "deepseek/deepseek-r1/community",
"reasoning": true,
"type": "chat",
+ "video": false,
"vision": false,
},
{
@@ -22,7 +23,21 @@ exports[`PPIO > models > should get models 1`] = `
"id": "deepseek/deepseek-v3/community",
"reasoning": false,
"type": "chat",
+ "video": false,
"vision": false,
},
+ {
+ "contextWindowTokens": 131072,
+ "description": "Qwen3.5 VL multimodal instruction model.",
+ "displayName": "Qwen3.5 VL 72B Instruct",
+ "enabled": false,
+ "functionCall": true,
+ "id": "qwen/qwen3.5-vl-72b-instruct",
+ "maxOutput": 32768,
+ "reasoning": true,
+ "type": "chat",
+ "video": true,
+ "vision": true,
+ },
]
`;
diff --git a/packages/model-runtime/src/providers/ppio/fixtures/models.json b/packages/model-runtime/src/providers/ppio/fixtures/models.json
index e6a631fd91b..4d179158278 100644
--- a/packages/model-runtime/src/providers/ppio/fixtures/models.json
+++ b/packages/model-runtime/src/providers/ppio/fixtures/models.json
@@ -32,5 +32,26 @@
"context_size": 64000,
"status": 1,
"display_name": "DeepSeek: DeepSeek V3 (community)"
+ },
+ {
+ "created": 1787107460,
+ "id": "qwen/qwen3.5-vl-72b-instruct",
+ "object": "model",
+ "owned_by": "unknown",
+ "permission": null,
+ "root": "",
+ "parent": "",
+ "input_token_price_per_m": 10000,
+ "output_token_price_per_m": 30000,
+ "title": "qwen/qwen3.5-vl-72b-instruct",
+ "description": "Qwen3.5 VL multimodal instruction model.",
+ "tags": [],
+ "context_size": 131072,
+ "status": 1,
+ "display_name": "Qwen3.5 VL 72B Instruct",
+ "model_type": "chat",
+ "max_output_tokens": 32768,
+ "features": ["serverless", "function-calling", "structured-outputs", "reasoning"],
+ "input_modalities": ["text", "image", "video"]
}
]
diff --git a/packages/model-runtime/src/providers/ppio/index.ts b/packages/model-runtime/src/providers/ppio/index.ts
index 1340eb6e34e..c835fdafdb4 100644
--- a/packages/model-runtime/src/providers/ppio/index.ts
+++ b/packages/model-runtime/src/providers/ppio/index.ts
@@ -28,6 +28,9 @@ export const LobePPIOAI = createOpenAICompatibleRuntime({
(m) => model.id.toLowerCase() === m.id.toLowerCase(),
);
+ // PPIO declares capabilities on the model card itself (`features`,
+ // `input_modalities`); prefer them over known-model / keyword fallbacks so
+ // models outside the curated list keep their native abilities
return {
contextWindowTokens: model.context_size,
description: model.description,
@@ -38,13 +41,20 @@ export const LobePPIOAI = createOpenAICompatibleRuntime({
model.title ||
model.id,
enabled: knownModel?.enabled || false,
- functionCall: knownModel?.abilities?.functionCall || false,
+ functionCall:
+ model.features?.includes('function-calling') ||
+ knownModel?.abilities?.functionCall ||
+ false,
id: model.id,
+ ...(model.max_output_tokens ? { maxOutput: model.max_output_tokens } : {}),
reasoning:
+ model.features?.includes('reasoning') ||
reasoningKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
knownModel?.abilities?.reasoning ||
false,
+ video: model.input_modalities?.includes('video') || knownModel?.abilities?.video || false,
vision:
+ model.input_modalities?.includes('image') ||
model.description.toLowerCase().includes('视觉') ||
knownModel?.abilities?.vision ||
false,
diff --git a/packages/model-runtime/src/providers/ppio/type.ts b/packages/model-runtime/src/providers/ppio/type.ts
index c3704ac0264..731e840ded5 100644
--- a/packages/model-runtime/src/providers/ppio/type.ts
+++ b/packages/model-runtime/src/providers/ppio/type.ts
@@ -3,8 +3,13 @@ export interface PPIOModelCard {
created: number;
description: string;
display_name: string;
+ /** e.g. `['serverless', 'function-calling', 'structured-outputs', 'reasoning']` */
+ features?: string[];
id: string;
+ /** e.g. `['text', 'image', 'video']` */
+ input_modalities?: string[];
input_token_price_per_m: number;
+ max_output_tokens?: number;
output_token_price_per_m: number;
status: number;
tags: string[];
diff --git a/packages/model-runtime/src/providers/qiniu/index.test.ts b/packages/model-runtime/src/providers/qiniu/index.test.ts
index 17c06daf908..25a02eb2d8c 100644
--- a/packages/model-runtime/src/providers/qiniu/index.test.ts
+++ b/packages/model-runtime/src/providers/qiniu/index.test.ts
@@ -102,6 +102,35 @@ describe('LobeQiniuAI - custom features', () => {
expect(models).toEqual([]);
});
+ it('should map upstream context_length/max_tokens onto the processed card', async () => {
+ const mockClient = {
+ models: {
+ list: vi.fn().mockResolvedValue({
+ data: [
+ {
+ context_length: 256000,
+ created: 1770370439,
+ id: 'meituan/longcat-flash-lite',
+ max_tokens: 320000,
+ object: 'model',
+ owned_by: 'system',
+ },
+ ],
+ }),
+ },
+ };
+
+ const models = await params.models!({ client: mockClient as any });
+
+ expect(models).toEqual([
+ expect.objectContaining({
+ contextWindowTokens: 256000,
+ id: 'meituan/longcat-flash-lite',
+ maxOutput: 320000,
+ }),
+ ]);
+ });
+
it('should handle API errors gracefully', async () => {
const mockClient = {
models: {
diff --git a/packages/model-runtime/src/providers/qiniu/index.ts b/packages/model-runtime/src/providers/qiniu/index.ts
index 1801ac0ef52..bbd6bb25354 100644
--- a/packages/model-runtime/src/providers/qiniu/index.ts
+++ b/packages/model-runtime/src/providers/qiniu/index.ts
@@ -13,8 +13,14 @@ export const params = {
models: async ({ client }) => {
const modelsPage = (await client.models.list()) as any;
const modelList = modelsPage.data.map((model: any) => {
- const { created: _created, ...rest } = model;
- return rest;
+ const { created: _created, context_length, max_tokens, ...rest } = model;
+ // Rename Qiniu's snake_case length fields to the card fields
+ // processMultiProviderModelList actually reads, so they aren't dropped
+ return {
+ ...rest,
+ contextWindowTokens: context_length,
+ maxOutput: max_tokens,
+ };
});
// Auto-detect the model provider and select the corresponding configuration