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

Function extractOpenclawFallbackModelIDs

agent/app/service/agents_utils.go:933–958  ·  view source on GitHub ↗
(conf map[string]interface{}, account *model.AgentAccount, accountModels []dto.AgentAccountModel, primaryModel string)

Source from the content-addressed store, hash-verified

931}
932
933func extractOpenclawFallbackModelIDs(conf map[string]interface{}, account *model.AgentAccount, accountModels []dto.AgentAccountModel, primaryModel string) []string {
934 modelMap := openclawModelRefMap(conf)
935 raw, ok := modelMap["fallbacks"].([]interface{})
936 if !ok || len(raw) == 0 {
937 return nil
938 }
939 resolved, err := buildOpenclawResolvedModelIDMap(account, accountModels)
940 if err != nil {
941 return nil
942 }
943 result := make([]string, 0, len(raw))
944 seen := make(map[string]struct{}, len(raw))
945 for _, item := range raw {
946 target := strings.TrimSpace(fmt.Sprintf("%v", item))
947 modelID, ok := resolved[target]
948 if !ok || sameProviderModelID(account.Provider, modelID, primaryModel) {
949 continue
950 }
951 if _, ok := seen[modelID]; ok {
952 continue
953 }
954 seen[modelID] = struct{}{}
955 result = append(result, modelID)
956 }
957 return result
958}
959
960func openclawModelRefMap(conf map[string]interface{}) map[string]interface{} {
961 agentsMap, ok := conf["agents"].(map[string]interface{})

Callers 2

GetModelConfigMethod · 0.85
syncAgentsByAccountMethod · 0.85

Calls 3

openclawModelRefMapFunction · 0.85
sameProviderModelIDFunction · 0.85

Tested by

no test coverage detected