Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

OpenAI model filter: fall back to the whole list when nothing in it looks like a chat model (the e2e stand-in serves model-a/model-b)

Duarte Santosacff80348f9a
diff --git a/api/coach/core/adapters/openai.js b/api/coach/core/adapters/openai.js
index b68e6b67a..02d8ee5f8 100644
--- a/api/coach/core/adapters/openai.js
+++ b/api/coach/core/adapters/openai.js
@@ -50,7 +50,11 @@ export function chatCompletionsSpec(id, { maxTokensField = 'max_completion_token
// looks right" out of eighty names lands on one Chat Completions refuses with a 400 or
// 404 the app can only show as "couldn't run". Keep what this request shape can use.
// A compatible endpoint (Ollama, LM Studio, OpenRouter) serves what it serves, unfiltered.
- return id === 'openai' ? ids.filter(isChatModel) : ids;
+ if (id !== 'openai') return ids;
+ // A proxy or stand-in that answers under OpenAI's own base URL may serve names the
+ // filter does not know; an empty picker would be worse than a long one.
+ const chat = ids.filter(isChatModel);
+ return chat.length ? chat : ids;
}
};
}
diff --git a/api/test/adapters-http.test.js b/api/test/adapters-http.test.js
index 385b3f3ae..dec527be6 100644
--- a/api/test/adapters-http.test.js
+++ b/api/test/adapters-http.test.js
@@ -272,6 +272,8 @@ test('models(): OpenAI’s list is cut to what Chat Completions can use; a compa
assert.deepEqual(all.filter(isChatModel), ['gpt-5.6', 'gpt-5.6-mini', 'gpt-4o', 'o3', 'o4-mini', 'chatgpt-4o-latest']);
const oa = fakeFetch([ok({ data: all.map(id => ({ id })) })]);
assert.deepEqual((await openai.models({}, env, { fetch: oa })).models, ['chatgpt-4o-latest', 'gpt-4o', 'gpt-5.6', 'gpt-5.6-mini', 'o3', 'o4-mini']);
+ const stub = fakeFetch([ok({ data: [{ id: 'model-b' }, { id: 'model-a' }] })]);
+ assert.deepEqual((await openai.models({}, env, { fetch: stub })).models, ['model-a', 'model-b'], 'a list with no recognisable chat model is served whole');
const { default: compatible } = await import('../coach/core/adapters/compatible.js');
const co = fakeFetch([ok({ data: [{ id: 'qwen2.5:3b' }, { id: 'llama3.2' }] })]);
assert.deepEqual((await compatible.models({ providerOptions: { compatible: { baseUrl: 'http://ollama:11434' } } }, {}, { fetch: co })).models, ['llama3.2', 'qwen2.5:3b']);