fix(gemini): log sync errors, optimize synced models query
- Replace silent catch blocks with logged errors in catalog and v1beta - Use SQL LIKE filter instead of fetching all rows and filtering in-memory
This commit is contained in:
@@ -349,8 +349,8 @@ export async function getUnifiedModelsResponse(
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// No synced models — show nothing for Gemini
|
||||
} catch (err) {
|
||||
console.error("[catalog] Error fetching synced Gemini models:", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ export async function GET() {
|
||||
...(m.supportsThinking === true ? { thinking: true } : {}),
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// No synced models — Gemini shows nothing
|
||||
} catch (err) {
|
||||
console.error("[v1beta/models] Error fetching synced Gemini models:", err);
|
||||
}
|
||||
|
||||
// Custom models (use stored metadata from provider APIs)
|
||||
|
||||
@@ -528,13 +528,12 @@ export interface SyncedAvailableModel {
|
||||
export async function getSyncedAvailableModels(providerId: string): Promise<SyncedAvailableModel[]> {
|
||||
const db = getDbInstance();
|
||||
const rows = db
|
||||
.prepare("SELECT key, value FROM key_value WHERE namespace = 'syncedAvailableModels'")
|
||||
.all();
|
||||
.prepare("SELECT key, value FROM key_value WHERE namespace = 'syncedAvailableModels' AND key LIKE ?")
|
||||
.all(`${providerId}:%`);
|
||||
const map = new Map<string, SyncedAvailableModel>();
|
||||
const prefix = `${providerId}:`;
|
||||
for (const row of rows) {
|
||||
const { key, value } = getKeyValue(row);
|
||||
if (!key || !key.startsWith(prefix) || value === null) continue;
|
||||
if (!key || value === null) continue;
|
||||
const models: SyncedAvailableModel[] = JSON.parse(value);
|
||||
for (const m of models) {
|
||||
if (m.id) map.set(m.id, m);
|
||||
|
||||
Reference in New Issue
Block a user