Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions bin/muse-proxy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ const resolveModelAndEffort = (requestedModel, requestedEffort) => {
}
}

// Contributor variants (#2753 amendment): the Meta pool's contributor
// models are distinct upstream ids (muse-spark-1.3-contributor,
// muse-wonder-1.0-contributor), optionally carrying an effort suffix
// AFTER the contributor part (muse-wonder-1.0-contributor-high — the
// effort suffix was already stripped above). Peel the contributor part
// off for the base-model lookup and re-attach it to the resolved ids,
// so the direct path sends the contributor id upstream verbatim. A
// plain base-model request keeps the plain id — contributor is the
// caller's choice, never a proxy rewrite.
let contributor = false;
if (modelStr.endsWith('-contributor')) {
contributor = true;
modelStr = modelStr.slice(0, -'-contributor'.length);
}

// Bare aliases
if (modelStr === 'spark' || modelStr === 'muse-spark') modelStr = 'muse-spark-1.3';
if (modelStr === 'wonder' || modelStr === 'muse-wonder') modelStr = 'muse-wonder-1.0';
Expand All @@ -101,10 +116,11 @@ const resolveModelAndEffort = (requestedModel, requestedEffort) => {
effort = modelConfig.defaultEffort;
}

const baseModel = contributor ? `${modelConfig.id}-contributor` : modelConfig.id;
return {
baseModel: modelConfig.id,
baseModel,
effort,
fullName: `${modelConfig.id}-${effort}`
fullName: `${baseModel}-${effort}`
};
};

Expand Down
34 changes: 34 additions & 0 deletions bin/muse-proxy.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -756,3 +756,37 @@ test('direct mode: missing auth.json leaves the exec path in charge (#2753)', as
assert.equal(health.direct.credentialFound, false);
assert.equal(health.direct.mintedKeyCached, false);
});

test('direct mode: contributor ids reach upstream verbatim, effort suffix parses after contributor (#2753)', async (t) => {
const meta = await startMetaStub('chat');
t.after(() => meta.close());
const { port, stop, home } = await startProxy({ MUSE_PROXY_META_API_BASE: meta.url });
t.after(stop);
writeStubAuth(home);

const wonder = JSON.parse(await chat(port, {
model: 'muse-wonder-1.0-contributor-high',
messages: [{ role: 'user', content: 'hi' }]
}));
assert.equal(wonder.model, 'muse-wonder-1.0-contributor-high');

const spark = JSON.parse(await chat(port, {
model: 'muse-spark-1.3-contributor',
messages: [{ role: 'user', content: 'hi' }]
}));
assert.equal(spark.model, 'muse-spark-1.3-contributor-high', 'no explicit effort means the default effort, contributor intact');

const plainBase = JSON.parse(await chat(port, {
model: 'muse-spark-1.3',
messages: [{ role: 'user', content: 'hi' }]
}));
assert.equal(plainBase.model, 'muse-spark-1.3-high', 'a plain request is NOT rewritten to contributor');

const sent = meta.requests.filter(r => r.url === '/v1/responses').map(r => JSON.parse(r.body));
assert.equal(sent.length, 3);
assert.equal(sent[0].model, 'muse-wonder-1.0-contributor', 'contributor id goes upstream verbatim');
assert.deepEqual(sent[0].reasoning, { effort: 'high' }, 'the effort suffix after -contributor is the effort');
assert.equal(sent[1].model, 'muse-spark-1.3-contributor');
assert.deepEqual(sent[1].reasoning, { effort: 'high' });
assert.equal(sent[2].model, 'muse-spark-1.3', 'plain base model stays plain upstream');
});