fix: include free OpenCode models without -free suffix in suggested models (#1535)
The "opencode-free" suggested-models filter only kept models whose id ends in "-free", so free-but-unsuffixed models like `big-pickle` (routed via open-sse/executors/opencode.js MESSAGES_MODELS) never appeared in the import UI. Extract the filters into a testable module and include a KNOWN_FREE_OPENCODE_MODELS allowlist (big-pickle) alongside the "-free" suffix check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
20
src/app/api/providers/suggested-models/filters.js
Normal file
20
src/app/api/providers/suggested-models/filters.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// Free OpenCode models that don't use the "-free" id suffix
|
||||
const KNOWN_FREE_OPENCODE_MODELS = ["big-pickle"];
|
||||
|
||||
export const FILTERS = {
|
||||
"openrouter-free": (models) =>
|
||||
models
|
||||
.filter(
|
||||
(m) =>
|
||||
m.pricing?.prompt === "0" &&
|
||||
m.pricing?.completion === "0" &&
|
||||
m.context_length >= 200000
|
||||
)
|
||||
.map((m) => ({ id: m.id, name: m.name, contextLength: m.context_length }))
|
||||
.sort((a, b) => b.contextLength - a.contextLength),
|
||||
|
||||
"opencode-free": (models) =>
|
||||
models
|
||||
.filter((m) => m.id?.endsWith("-free") || KNOWN_FREE_OPENCODE_MODELS.includes(m.id))
|
||||
.map((m) => ({ id: m.id, name: m.id })),
|
||||
};
|
||||
@@ -1,25 +1,8 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { FILTERS } from "./filters.js";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const FILTERS = {
|
||||
"openrouter-free": (models) =>
|
||||
models
|
||||
.filter(
|
||||
(m) =>
|
||||
m.pricing?.prompt === "0" &&
|
||||
m.pricing?.completion === "0" &&
|
||||
m.context_length >= 200000
|
||||
)
|
||||
.map((m) => ({ id: m.id, name: m.name, contextLength: m.context_length }))
|
||||
.sort((a, b) => b.contextLength - a.contextLength),
|
||||
|
||||
"opencode-free": (models) =>
|
||||
models
|
||||
.filter((m) => m.id?.endsWith("-free"))
|
||||
.map((m) => ({ id: m.id, name: m.id })),
|
||||
};
|
||||
|
||||
export async function GET(request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const url = searchParams.get("url");
|
||||
|
||||
Reference in New Issue
Block a user