MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / restoreModelSelections

Method restoreModelSelections

app/src/AI/Assistant.cpp:735–762  ·  view source on GitHub ↗

* @brief Loads each provider's previously-selected model from QSettings. */

Source from the content-addressed store, hash-verified

733 * @brief Loads each provider's previously-selected model from QSettings.
734 */
735void AI::Assistant::restoreModelSelections()
736{
737 m_settings.beginGroup(QStringLiteral("ai/model"));
738 for (int i = 0; i < kProviderCount; ++i) {
739 const auto stored = m_settings.value(modelSettingsKey(i)).toString();
740 if (stored.isEmpty())
741 continue;
742
743 auto* p = providerAt(i);
744 if (!p)
745 continue;
746
747 if (i == static_cast<int>(ProviderId::Local)) {
748 p->setCurrentModel(stored);
749 continue;
750 }
751
752 if (!p->availableModels().contains(stored)) {
753 qCInfo(serialStudioAI) << "Discarding stale model id" << stored << "for provider" << i
754 << "-- not in availableModels";
755 m_settings.remove(modelSettingsKey(i));
756 continue;
757 }
758
759 p->setCurrentModel(stored);
760 }
761 m_settings.endGroup();
762}
763
764/**
765 * @brief Returns the QSettings sub-key name for the provider's model.

Callers

nothing calls this directly

Calls 6

isEmptyMethod · 0.80
valueMethod · 0.45
setCurrentModelMethod · 0.45
containsMethod · 0.45
availableModelsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected