fix: filter real openrouter free model
Browse files
src/utils/model/openRouterModels.ts
CHANGED
|
@@ -65,8 +65,45 @@ export async function fetchOpenRouterModels(
|
|
| 65 |
const data = await response.json()
|
| 66 |
const models: OpenRouterModel[] = data.data || []
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
// Convert to ModelOption format
|
| 69 |
-
const options: ModelOption[] =
|
| 70 |
// Truncate description if too long
|
| 71 |
let description = model.description || model.id
|
| 72 |
if (description.length > 100) {
|
|
|
|
| 65 |
const data = await response.json()
|
| 66 |
const models: OpenRouterModel[] = data.data || []
|
| 67 |
|
| 68 |
+
// Filter out non-model items (routers, aggregators, etc.)
|
| 69 |
+
const validModels = models.filter(model => {
|
| 70 |
+
const id = model.id.toLowerCase()
|
| 71 |
+
const name = model.name.toLowerCase()
|
| 72 |
+
|
| 73 |
+
// Skip items that are routers, aggregators, or services
|
| 74 |
+
const skipPatterns = [
|
| 75 |
+
'router',
|
| 76 |
+
'aggregator',
|
| 77 |
+
'aggregation',
|
| 78 |
+
'free.*router',
|
| 79 |
+
'routing',
|
| 80 |
+
'service',
|
| 81 |
+
'platform',
|
| 82 |
+
'hub',
|
| 83 |
+
]
|
| 84 |
+
|
| 85 |
+
// Skip if ID or name matches any skip pattern
|
| 86 |
+
for (const pattern of skipPatterns) {
|
| 87 |
+
if (new RegExp(pattern).test(id) || new RegExp(pattern).test(name)) {
|
| 88 |
+
return false
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
// Skip items without proper model ID format (should contain provider/model)
|
| 93 |
+
if (!id.includes('/') || id.startsWith('router') || id.startsWith('free')) {
|
| 94 |
+
return false
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Skip items without pricing information
|
| 98 |
+
if (!model.pricing || !model.pricing.prompt || !model.pricing.completion) {
|
| 99 |
+
return false
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
return true
|
| 103 |
+
})
|
| 104 |
+
|
| 105 |
// Convert to ModelOption format
|
| 106 |
+
const options: ModelOption[] = validModels.map(model => {
|
| 107 |
// Truncate description if too long
|
| 108 |
let description = model.description || model.id
|
| 109 |
if (description.length > 100) {
|