mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-25 15:17:23 +00:00
Merge pull request #4681 from HanadHassan/HH/alibaba-catalog-snapshot-aliases
fix(ai): Alibaba snapshot names fold into the curated model instead of listing unpriced
This commit is contained in:
2 files changed
+64
-5
No files matched your search
@@ -960,6 +960,50 @@ describe('Alibaba official catalog', () => {
|
||||
expect(model).toBeNull();
|
||||
});
|
||||
|
||||
it.each([
|
||||
['qwen3.6-plus-2026-04-02', 'qwen3.6-plus'],
|
||||
['qwen-plus-latest', 'qwen-plus-2025-12-01'],
|
||||
])(
|
||||
'lists %s once, as the priced %s, and keeps its alibaba: name routable',
|
||||
async (alias, curatedId) => {
|
||||
axiosGetMock.mockReset();
|
||||
axiosGetMock.mockResolvedValueOnce({
|
||||
data: {
|
||||
success: true,
|
||||
output: {
|
||||
page_no: 1,
|
||||
total: 1,
|
||||
models: [
|
||||
{
|
||||
model: alias,
|
||||
capabilities: ['TG', 'Reasoning'],
|
||||
inference_metadata: {
|
||||
request_modality: ['Text'],
|
||||
response_modality: ['Text'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
const { provider } = makeProvider();
|
||||
const models = await provider.models();
|
||||
expect(models.some((model) => model.id === alias)).toBe(false);
|
||||
const curated = ALIBABA_MODELS.find(
|
||||
(model) => model.id === curatedId,
|
||||
)!;
|
||||
const listed = models.filter(
|
||||
(model) => model.puterId === curated.puterId,
|
||||
);
|
||||
expect(listed).toHaveLength(1);
|
||||
expect(listed[0].costs).toBe(curated.costs);
|
||||
// The chat driver routes by aliases, so the alibaba: spelling must
|
||||
// stay one.
|
||||
expect(listed[0].aliases).toContain(`alibaba:qwen/${alias}`);
|
||||
expect(curated.aliases).not.toContain(`alibaba:qwen/${alias}`);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
[
|
||||
'ASR',
|
||||
|
||||
@@ -85,6 +85,11 @@ const positiveLimit = (value: unknown): number | undefined =>
|
||||
const chatCapabilities = ['TG', 'Reasoning', 'VU'];
|
||||
|
||||
const curatedPuterIds = new Set(ALIBABA_MODELS.map((model) => model.puterId));
|
||||
const curatedAliasOwners = new Map(
|
||||
ALIBABA_MODELS.flatMap((model) =>
|
||||
(model.aliases ?? []).map((alias) => [alias, model.id] as const),
|
||||
),
|
||||
);
|
||||
|
||||
const inferPuterId = (id: string): string => {
|
||||
if (id.includes('/')) return `alibaba:${id}`;
|
||||
@@ -267,11 +272,21 @@ export const fetchAlibabaCatalog = async (
|
||||
for (const raw of entries) {
|
||||
if (typeof raw.model !== 'string' || !raw.model.trim())
|
||||
throw new Error('Invalid Alibaba model id');
|
||||
seen.add(raw.model.trim());
|
||||
const model = mapAlibabaCatalogModel(
|
||||
raw,
|
||||
models.get(raw.model.trim()),
|
||||
);
|
||||
const id = raw.model.trim();
|
||||
seen.add(id);
|
||||
// A snapshot or -latest name that a curated model carries as an alias
|
||||
// names that model, so its alibaba: spelling becomes one more alias.
|
||||
const owner = models.get(curatedAliasOwners.get(id) ?? '');
|
||||
if (owner) {
|
||||
const name = inferPuterId(id);
|
||||
if (name !== owner.puterId && !owner.aliases?.includes(name))
|
||||
models.set(owner.id, {
|
||||
...owner,
|
||||
aliases: [...(owner.aliases ?? []), name],
|
||||
});
|
||||
continue;
|
||||
}
|
||||
const model = mapAlibabaCatalogModel(raw, models.get(id));
|
||||
if (model) models.set(model.id, model);
|
||||
}
|
||||
if (models.size > 20_000)
|
||||
|
||||
Reference in new issue
Block a user