MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / listPersistedAgentAccountModels

Function listPersistedAgentAccountModels

agent/app/service/agents_utils.go:1227–1252  ·  view source on GitHub ↗
(accountID uint)

Source from the content-addressed store, hash-verified

1225}
1226
1227func 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
1254func replacePersistedAgentAccountModelsWithTx(tx *gorm.DB, accountID uint, models []dto.AgentAccountModel) error {
1255 if err := tx.Where("account_id = ?", accountID).Delete(&model.AgentAccountModel{}).Error; err != nil {

Callers 1

loadAgentAccountModelsFunction · 0.85

Calls 2

ListMethod · 0.65

Tested by

no test coverage detected