fix(pi): converge worker failures and thinking state

This commit is contained in:
2026-08-25 11:45:14 +08:00
parent 274187e3cf
commit 61817b161f
28 changed files with 2019 additions and 118 deletions

View File

@@ -41,9 +41,11 @@ export interface PiProviderModelDescriptor {
contextWindow?: number;
maxOutputTokens?: number;
compat?: {
thinkingFormat: 'openrouter';
sessionAffinityFormat: 'openrouter';
thinkingFormat?: 'deepseek' | 'openrouter';
sessionAffinityFormat?: 'openrouter';
requiresReasoningContentOnAssistantMessages?: boolean;
};
thinkingLevelMap?: Partial<Record<ProductModelRef['thinkingLevel'], string | null>>;
}
export interface PiProviderDescriptor {
@@ -71,6 +73,7 @@ export interface PiModelsFile {
maxTokens?: number;
cost: { input: number; output: number; cacheRead: number; cacheWrite: number };
compat?: PiProviderModelDescriptor['compat'];
thinkingLevelMap?: PiProviderModelDescriptor['thinkingLevelMap'];
}>;
}>;
}
@@ -312,10 +315,17 @@ function modelDescriptor(
id: modelId,
name: summary?.name || (typeof backend?.name === 'string' && backend.name.trim()) || modelId,
input: supportsImage ? ['text', 'image'] : ['text'],
reasoning: summary?.supportsReasoning === true || backend?.reasoning === true,
reasoning: summary?.supportsReasoning === true
|| profile?.pi?.reasoning === true
|| backend?.reasoning === true,
...(contextWindow ? { contextWindow } : {}),
...(maxOutputTokens ? { maxOutputTokens } : {}),
...(compat ? { compat } : {}),
...(compat || profile?.pi?.compat
? { compat: { ...compat, ...profile?.pi?.compat } }
: {}),
...(profile?.pi?.thinkingLevelMap
? { thinkingLevelMap: { ...profile.pi.thinkingLevelMap } }
: {}),
};
}
@@ -403,6 +413,9 @@ function modelsFileForDescriptors(descriptors: readonly PiProviderDescriptor[]):
...(model.maxOutputTokens ? { maxTokens: model.maxOutputTokens } : {}),
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
...(model.compat ? { compat: { ...model.compat } } : {}),
...(model.thinkingLevelMap
? { thinkingLevelMap: { ...model.thinkingLevelMap } }
: {}),
})),
},
])),