mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-09 11:01:22 +00:00
fix: ollama settings sync (#617)
* fix: Updated Ollama settings to sort models and add available models. 1) sort ollama models list when select the model from settings 2) fix: settings of cached ollama models need update 3) sort cached ollama models * remove code comments * remove code comments --------- Co-authored-by: neo <yifei0727@no-reply.users.github.io>
This commit is contained in:
parent
f49de84607
commit
91e72a79fd
1 changed files with 18 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package ee.carlrobert.codegpt.settings.service.ollama
|
||||
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.application.ReadAction
|
||||
import com.intellij.openapi.components.service
|
||||
|
|
@ -155,6 +156,9 @@ class OllamaSettingsForm {
|
|||
.modelTags
|
||||
.models
|
||||
.map { it.name }
|
||||
.sortedWith(compareBy({ it.split(":").first() }, {
|
||||
if (it.contains("latest")) 1 else 0
|
||||
}))
|
||||
} catch (t: Throwable) {
|
||||
handleModelLoadingError(t)
|
||||
throw t
|
||||
|
|
@ -187,6 +191,20 @@ class OllamaSettingsForm {
|
|||
} else {
|
||||
modelComboBox.model = DefaultComboBoxModel(arrayOf("No models"))
|
||||
}
|
||||
val availableModels = ApplicationManager.getApplication()
|
||||
.getService(OllamaSettings::class.java)
|
||||
.state.availableModels
|
||||
availableModels.removeAll { !models.contains(it) }
|
||||
models.forEach { model ->
|
||||
if (!availableModels.contains(model)) {
|
||||
availableModels.add(model)
|
||||
}
|
||||
}
|
||||
availableModels.sortWith(
|
||||
compareBy({ it.split(":").first() }, {
|
||||
if (it.contains("latest")) 1 else 0
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun handleModelLoadingError(ex: Throwable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue