(accountID uint)
| 1225 | } |
| 1226 | |
| 1227 | func listPersistedAgentAccountModels(accountID uint) ([]dto.AgentAccountModel, error) { |
| 1228 | if accountID == 0 { |
| 1229 | return nil, nil |
| 1230 | } |
| 1231 | rows, err := agentAccountModelRepo.List(repo.WithByAccountID(accountID), repo.WithOrderAsc("sort_order"), repo.WithOrderAsc("id")) |
| 1232 | if err != nil { |
| 1233 | return nil, err |
| 1234 | } |
| 1235 | result := make([]dto.AgentAccountModel, 0, len(rows)) |
| 1236 | for _, row := range rows { |
| 1237 | inputs := []string{} |
| 1238 | if strings.TrimSpace(row.Input) != "" { |
| 1239 | _ = json.Unmarshal([]byte(row.Input), &inputs) |
| 1240 | } |
| 1241 | result = append(result, dto.AgentAccountModel{ |
| 1242 | RecordID: row.ID, |
| 1243 | ID: strings.TrimSpace(row.Model), |
| 1244 | Name: strings.TrimSpace(row.Name), |
| 1245 | ContextWindow: row.ContextWindow, |
| 1246 | MaxTokens: row.MaxTokens, |
| 1247 | Reasoning: row.Reasoning, |
| 1248 | Input: sanitizeAgentAccountModelInputs(inputs), |
| 1249 | }) |
| 1250 | } |
| 1251 | return result, nil |
| 1252 | } |
| 1253 | |
| 1254 | func replacePersistedAgentAccountModelsWithTx(tx *gorm.DB, accountID uint, models []dto.AgentAccountModel) error { |
| 1255 | if err := tx.Where("account_id = ?", accountID).Delete(&model.AgentAccountModel{}).Error; err != nil { |
no test coverage detected