- Add catalog metadata lookup for better error messages with hints (e.g., for missing manifests or tags) - Persist downloaded model references in saved remote models for future reuse - Replace searchRemoteModels import with getSavedRemoteModels in search route - Enhance pull progress UI to display download bytes, digest, and fallback message when data is unavailable - Improve error payload with model details, URL, and tags count to guide users toward valid tags or models
33 lines
954 B
TypeScript
33 lines
954 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getSavedRemoteModels } from "@/lib/user-remote-models";
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const query = searchParams.get("q") || undefined;
|
|
|
|
const saved = await getSavedRemoteModels();
|
|
const q = (query || "").trim().toLowerCase();
|
|
const filtered = q
|
|
? saved.filter((m) => m.name.toLowerCase().includes(q))
|
|
: saved;
|
|
|
|
const models = filtered.map((m) => ({
|
|
name: m.name,
|
|
description: m.description,
|
|
url: m.url,
|
|
tags_count: m.tags_count,
|
|
installed: m.installed === true,
|
|
remote: true,
|
|
}));
|
|
|
|
return NextResponse.json({ success: true, models });
|
|
} catch (error) {
|
|
console.error("Error searching remote models:", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to search remote models" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|