MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetTaskPluginOptions

Function GetTaskPluginOptions

controller/task_plugin.go:947–1035  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

945}
946
947func GetTaskPluginOptions(c *gin.Context) {
948 snapshot := jsplugin.DefaultRegistry.Snapshot()
949 seen := make(map[string]bool)
950 options := make([]gin.H, 0, len(snapshot.Factory)+len(snapshot.Override))
951 for layer, metas := range [][]jsplugin.Meta{snapshot.Override, snapshot.Factory} {
952 for _, meta := range metas {
953 if seen[meta.Key] {
954 continue
955 }
956 // Disabled factory keys are omitted from bind options. The disabled
957 // set suppresses only the factory fallback; an enabled override for
958 // the same key is listed in the override pass and still appears.
959 if layer == 1 && setting.IsTaskPluginFactoryDisabled(meta.Key) {
960 continue
961 }
962 loaded, ok := jsplugin.DefaultRegistry.Get(meta.Key)
963 switchedOff := !ok
964 if switchedOff {
965 // With the master switch off, a plugin's request processing
966 // part still runs; its channel parts do not.
967 if loaded, ok = jsplugin.DefaultRegistry.GetIgnoringMasterSwitch(meta.Key); !ok || !loaded.Meta.HasTransformPart() {
968 continue
969 }
970 }
971 parts := loadedTaskPluginParts(loaded)
972 if switchedOff {
973 parts.Task, parts.Provider, parts.Login, parts.Refresh = false, false, false, false
974 }
975 seen[meta.Key] = true
976 hasIcon := false
977 if layer == 0 {
978 if row, rowErr := model.GetTaskPluginVersion(meta.Key, ""); rowErr == nil {
979 hasIcon = row.HasIcon()
980 }
981 } else {
982 _, _, hasIcon = plugins.Icon(meta.Key)
983 }
984 option := gin.H{
985 "key": meta.Key,
986 "name": meta.Name,
987 "description": meta.Description,
988 "icon": meta.Icon,
989 "hasIcon": hasIcon,
990 "baseUrl": meta.BaseURL,
991 "sortPriority": meta.SortPriority,
992 "website": meta.Website,
993 "models": meta.Models,
994 "channelTypes": meta.ChannelTypes,
995 "upstreams": meta.Upstreams,
996 "usageSchema": meta.UsageSchema,
997 "usageProfiles": meta.UsageProfiles,
998 "configSchema": meta.ConfigSchema,
999 "task": parts.Task,
1000 "provider": parts.Provider,
1001 "transform": parts.Transform,
1002 "transform_hooks": parts.TransformHooks,
1003 "samples": append([]jsplugin.Sample{}, meta.Samples...),
1004 "optional": meta.Optional,

Calls 14

GetTaskPluginVersionFunction · 0.92
IconFunction · 0.92
ApiSuccessFunction · 0.92
loadedTaskPluginPartsFunction · 0.85
relayPathsFunction · 0.85
relayRouteOptionsFunction · 0.85
HasTransformPartMethod · 0.80
HasIconMethod · 0.80
HasProviderHookMethod · 0.80