| 139 | } |
| 140 | |
| 141 | void AddModelDialogPrivate::slotAddModel() |
| 142 | { |
| 143 | LLMInfo newLLMInfo; |
| 144 | newLLMInfo.modelName = leLLMName->text(); |
| 145 | if (newLLMInfo.modelName.isEmpty()) { |
| 146 | leLLMName->showAlertMessage(ModelConfigDialog::tr("This field cannot be empty.")); |
| 147 | return; |
| 148 | } |
| 149 | newLLMInfo.type = cbLLMType->currentData().value<LLMType>(); |
| 150 | if (newLLMInfo.type == LLMType::OPENAI) |
| 151 | newLLMInfo.icon = QIcon::fromTheme("uc_openai"); |
| 152 | |
| 153 | newLLMInfo.modelPath = leApiUrl->text(); |
| 154 | if (newLLMInfo.modelPath.isEmpty()) { |
| 155 | leApiUrl->showAlertMessage(ModelConfigDialog::tr("This field cannot be empty.")); |
| 156 | return; |
| 157 | } |
| 158 | newLLMInfo.apikey = leApiKey->text(); |
| 159 | |
| 160 | showWaitingState(true); |
| 161 | QString errStr; |
| 162 | auto valid = AiManager::instance()->checkModelValid(newLLMInfo, &errStr); |
| 163 | if (valid) { |
| 164 | LLMAppended = newLLMInfo; |
| 165 | q->accept(); |
| 166 | } else if (!errStr.isEmpty() && q->isVisible()) { // if dialog closed, do not show error info |
| 167 | showErrorInfoDialog(errStr); |
| 168 | } |
| 169 | showWaitingState(false); |
| 170 | } |
| 171 | |
| 172 | void AddModelDialogPrivate::showWaitingState(bool waiting) |
| 173 | { |
nothing calls this directly
no test coverage detected