mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 11:39:26 +01:00
fix: filter cloud models from API response
This commit is contained in:
parent
d4cbc0c2d5
commit
a91c13867d
|
|
@ -221,10 +221,18 @@ export class OllamaService {
|
|||
return null
|
||||
}
|
||||
|
||||
const models = response.data.models as NomadOllamaModel[]
|
||||
const rawModels = response.data.models as NomadOllamaModel[]
|
||||
|
||||
await this.writeModelsToCache(models)
|
||||
return this.sortModels(models, sort)
|
||||
// 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(noCloud)
|
||||
return this.sortModels(noCloud, sort)
|
||||
} catch (error) {
|
||||
logger.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[] {
|
||||
const options: IFuseOptions<NomadOllamaModel> = {
|
||||
ignoreDiacritics: true,
|
||||
keys: ['name', 'description', 'tags.tag'],
|
||||
keys: ['name', 'description', 'tags.name'],
|
||||
threshold: 0.3, // lower threshold for stricter matching
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export type NomadOllamaModelTag = {
|
|||
size: string
|
||||
context: string
|
||||
input: string
|
||||
cloud: boolean
|
||||
}
|
||||
|
||||
export type NomadOllamaModelAPIResponse = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user