@@ -183,25 +183,32 @@ export class OllamaService {
183183 }
184184
185185 async getAvailableModels (
186- { sort, recommendedOnly, query } : { sort ?: 'pulls' | 'name' ; recommendedOnly ?: boolean , query : string | null } = {
186+ { sort, recommendedOnly, query, limit } : { sort ?: 'pulls' | 'name' ; recommendedOnly ?: boolean , query : string | null , limit ?: number } = {
187187 sort : 'pulls' ,
188188 recommendedOnly : false ,
189189 query : null ,
190+ limit : 15 ,
190191 }
191- ) : Promise < NomadOllamaModel [ ] | null > {
192+ ) : Promise < { models : NomadOllamaModel [ ] , hasMore : boolean } | null > {
192193 try {
193194 const models = await this . retrieveAndRefreshModels ( sort )
194195 if ( ! models ) {
195196 // If we fail to get models from the API, return the fallback recommended models
196197 logger . warn (
197198 '[OllamaService] Returning fallback recommended models due to failure in fetching available models'
198199 )
199- return FALLBACK_RECOMMENDED_OLLAMA_MODELS
200+ return {
201+ models : FALLBACK_RECOMMENDED_OLLAMA_MODELS ,
202+ hasMore : false
203+ }
200204 }
201205
202206 if ( ! recommendedOnly ) {
203207 const filteredModels = query ? this . fuseSearchModels ( models , query ) : models
204- return filteredModels
208+ return {
209+ models : filteredModels . slice ( 0 , limit || 15 ) ,
210+ hasMore : filteredModels . length > ( limit || 15 )
211+ }
205212 }
206213
207214 // If recommendedOnly is true, only return the first three models (if sorted by pulls, these will be the top 3)
@@ -217,10 +224,17 @@ export class OllamaService {
217224 } )
218225
219226 if ( query ) {
220- return this . fuseSearchModels ( recommendedModels , query )
227+ const filteredRecommendedModels = this . fuseSearchModels ( recommendedModels , query )
228+ return {
229+ models : filteredRecommendedModels ,
230+ hasMore : filteredRecommendedModels . length > ( limit || 15 )
231+ }
221232 }
222233
223- return recommendedModels
234+ return {
235+ models : recommendedModels ,
236+ hasMore : recommendedModels . length > ( limit || 15 )
237+ }
224238 } catch ( error ) {
225239 logger . error (
226240 `[OllamaService] Failed to get available models: ${ error instanceof Error ? error . message : error } `
@@ -253,7 +267,7 @@ export class OllamaService {
253267 }
254268
255269 const rawModels = response . data . models as NomadOllamaModel [ ]
256-
270+
257271 // Filter out tags where cloud is truthy, then remove models with no remaining tags
258272 const noCloud = rawModels
259273 . map ( ( model ) => ( {
0 commit comments