File tree Expand file tree Collapse file tree 1 file changed +31
-15
lines changed
src/main/presenter/llmProviderPresenter/providers Expand file tree Collapse file tree 1 file changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -323,21 +323,37 @@ export class OllamaProvider extends BaseLLMProvider {
323323 }
324324
325325 private async attachModelInfo ( model : OllamaModel ) : Promise < OllamaModel > {
326- const showResponse = await this . showModelInfo ( model . name )
327- const info = showResponse . model_info
328- const family = model . details . family
329- const context_length = info ?. [ family + '.context_length' ] ?? 4096
330- const embedding_length = info ?. [ family + '.embedding_length' ] ?? 512
331- const capabilities = showResponse . capabilities ?? [ 'chat' ]
332-
333- // Merge customConfig properties to model
334- return {
335- ...model ,
336- model_info : {
337- context_length,
338- embedding_length
339- } ,
340- capabilities
326+ try {
327+ const showResponse = await this . showModelInfo ( model . name )
328+ const info = showResponse . model_info
329+ const family = model . details . family
330+ const context_length = info ?. [ family + '.context_length' ] ?? 4096
331+ const embedding_length = info ?. [ family + '.embedding_length' ] ?? 512
332+ const capabilities = showResponse . capabilities ?? [ 'chat' ]
333+
334+ // Merge customConfig properties to model
335+ return {
336+ ...model ,
337+ model_info : {
338+ context_length,
339+ embedding_length
340+ } ,
341+ capabilities
342+ }
343+ } catch ( error ) {
344+ // If showModelInfo fails, return the model with default info
345+ console . warn (
346+ `Failed to get info for model ${ model . name } , using defaults:` ,
347+ ( error as Error ) . message
348+ )
349+ return {
350+ ...model ,
351+ model_info : {
352+ context_length : 4096 ,
353+ embedding_length : 512
354+ } ,
355+ capabilities : [ 'chat' ]
356+ }
341357 }
342358 }
343359
You can’t perform that action at this time.
0 commit comments