fix: filter cloud models from API response

This commit is contained in:
Jake Turner 2026-02-04 17:04:31 -08:00 committed by Jake Turner
parent d4cbc0c2d5
commit a91c13867d
2 changed files with 13 additions and 4 deletions

View File

@ -221,10 +221,18 @@ export class OllamaService {
return null return null
} }
const models = response.data.models as NomadOllamaModel[] const rawModels = response.data.models as NomadOllamaModel[]
// Filter out tags where cloud is truthy, then remove models with no remaining tags
const noCloud = rawModels
.map((model) => ({
...model,
tags: model.tags.filter((tag) => !tag.cloud),
}))
.filter((model) => model.tags.length > 0)
await this.writeModelsToCache(models) await this.writeModelsToCache(noCloud)
return this.sortModels(models, sort) return this.sortModels(noCloud, sort)
} catch (error) { } catch (error) {
logger.error( logger.error(
`[OllamaService] Failed to retrieve models from Nomad API: ${error instanceof Error ? error.message : error `[OllamaService] Failed to retrieve models from Nomad API: ${error instanceof Error ? error.message : error
@ -333,7 +341,7 @@ export class OllamaService {
private fuseSearchModels(models: NomadOllamaModel[], query: string): NomadOllamaModel[] { private fuseSearchModels(models: NomadOllamaModel[], query: string): NomadOllamaModel[] {
const options: IFuseOptions<NomadOllamaModel> = { const options: IFuseOptions<NomadOllamaModel> = {
ignoreDiacritics: true, ignoreDiacritics: true,
keys: ['name', 'description', 'tags.tag'], keys: ['name', 'description', 'tags.name'],
threshold: 0.3, // lower threshold for stricter matching threshold: 0.3, // lower threshold for stricter matching
} }

View File

@ -13,6 +13,7 @@ export type NomadOllamaModelTag = {
size: string size: string
context: string context: string
input: string input: string
cloud: boolean
} }
export type NomadOllamaModelAPIResponse = { export type NomadOllamaModelAPIResponse = {