Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@
* @property {Array} platform
*/
compatibility(): Compatibility | undefined {
return undefined
}

Check warning on line 94 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

93-94 lines are not covered with tests

/**
* Registers models - it persists in-memory shared ModelManager instance's data map.
* @param models
*/
async registerModels(models: Model[]): Promise<void> {
for (const model of models) {
ModelManager.instance().register(model)
}
}

Check warning on line 104 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

101-104 lines are not covered with tests

/**
* Register settings for the extension.
Expand All @@ -110,9 +110,9 @@
*/
async registerSettings(settings: SettingComponentProps[]): Promise<void> {
if (!this.name) {
console.error('Extension name is not defined')
return
}

Check warning on line 115 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

113-115 lines are not covered with tests

settings.forEach((setting) => {
setting.extensionName = this.name
Expand All @@ -121,19 +121,23 @@
const oldSettingsJson = localStorage.getItem(this.name)
// Persists new settings
if (oldSettingsJson) {
const oldSettings = JSON.parse(oldSettingsJson)
settings.forEach((setting) => {

Check warning on line 125 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

124-125 lines are not covered with tests
// Keep setting value
if (setting.controllerProps && Array.isArray(oldSettings))
setting.controllerProps.value = oldSettings.find(
(e: any) => e.key === setting.key
)?.controllerProps?.value
if ('options' in setting.controllerProps)
setting.controllerProps.options = setting.controllerProps.options?.length
? setting.controllerProps.options
: oldSettings.find((e: any) => e.key === setting.key)?.controllerProps?.options
})
}

Check warning on line 136 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

127-136 lines are not covered with tests
localStorage.setItem(this.name, JSON.stringify(settings))
} catch (err) {
console.error(err)
}

Check warning on line 140 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

139-140 lines are not covered with tests
}

/**
Expand Down Expand Up @@ -167,18 +171,18 @@
* @returns
*/
async getSettings(): Promise<SettingComponentProps[]> {
if (!this.name) return []

Check warning on line 174 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

174 line is not covered with tests

try {
const settingsString = localStorage.getItem(this.name)
if (!settingsString) return []
const settings: SettingComponentProps[] = JSON.parse(settingsString)
return settings
} catch (err) {
console.warn(err)
return []
}
}

Check warning on line 185 in core/src/browser/extension.ts

View workflow job for this annotation

GitHub Actions / coverage-check

176-185 lines are not covered with tests

/**
* Update the settings for the extension.
Expand Down
24 changes: 14 additions & 10 deletions web-app/src/hooks/useModelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,28 @@
selectedModel: null,
deletedModels: [],
getModelBy: (modelId: string) => {
const provider = get().providers.find(
(provider) => provider.provider === get().selectedProvider
)
if (!provider) return undefined
return provider.models.find((model) => model.id === modelId)
},

Check warning on line 36 in web-app/src/hooks/useModelProvider.ts

View workflow job for this annotation

GitHub Actions / coverage-check

31-36 lines are not covered with tests
setProviders: (providers) =>
set((state) => {
const existingProviders = state.providers.map((provider) => {
return {
...provider,
models: provider.models.filter(
(e) =>
('id' in e || 'model' in e) &&
typeof (e.id ?? e.model) === 'string'
),
}
})
const existingProviders = state.providers

Check warning on line 39 in web-app/src/hooks/useModelProvider.ts

View workflow job for this annotation

GitHub Actions / coverage-check

38-39 lines are not covered with tests
// Filter out legacy llama.cpp provider for migration
// Can remove after a couple of releases
.filter((e) => e.provider !== 'llama.cpp')
.map((provider) => {
return {
...provider,
models: provider.models.filter(
(e) =>
('id' in e || 'model' in e) &&
typeof (e.id ?? e.model) === 'string'
),
}
})
// Ensure deletedModels is always an array
const currentDeletedModels = Array.isArray(state.deletedModels)
? state.deletedModels
Expand Down
Loading