Switch generation to RunPod completions endpoint and make model optional#45
Switch generation to RunPod completions endpoint and make model optional#45
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1649640c8e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!modelConfig) { | ||
| return res.status(400).json({ error: "Invalid model specified" }); | ||
| return res.status(500).json({ error: "No models configured" }); |
There was a problem hiding this comment.
Return client error for unknown model IDs
validateGenerateRequestBody only checks that model is a non-empty string, so a request like { model: "does-not-exist" } reaches generateText; with the new fallback logic, selectedModelId is set to that invalid string and getModel returns undefined, which now returns HTTP 500 ("No models configured") instead of a 4xx invalid-model error. This turns a user input mistake into a server error and can trigger misleading alerts/retries for bad client requests.
Useful? React with 👍 / 👎.
| const completionsApiKey = | ||
| process.env.LOOMPAD_COMPLETIONS_API_KEY?.trim() || "not-required"; |
There was a problem hiding this comment.
Fail fast when completions key is missing
validateConfig now always supplies a placeholder ("not-required") when LOOMPAD_COMPLETIONS_API_KEY is unset, but /api/judge still calls OpenRouter (judge.ts) with apiKey: config.completionsApiKey; in production this allows boot to succeed and then makes judge requests fail at runtime with auth errors. The previous behavior guarded against this by requiring a real key outside development.
Useful? React with 👍 / 👎.
Motivation
modeland still produce output by falling back to a configured model.Description
https://xob3rm6bnyl1j1-8000.proxy.runpod.net/v1and to useconfig.completionsApiKeyinstead of the previous OpenRouter key and headers (server/apis/openaiClient.ts).LOOMPAD_COMPLETIONS_API_KEYbackedcompletionsApiKeyfield inserver/config.ts(defaulted to a safe string for non-production use).modeloptional inGenerateRequestBodyand changed validation somodelis only validated when present (server/apis/validators.ts).generateTextto resolve a model config from the providedmodelor fall back to the first configured model and stopped sendingmodelin the upstream/completionsrequest payload (server/apis/generation.ts).completionsApiKeyconfig field (server/apis/judge.ts).server/__tests__/validators.test.ts.Testing
bun test server/__tests__/validators.test.tsand all validator tests passed.bun testand all tests passed (no failures).Codex Task