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

Function GetTaskPluginOptions

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

Source from the content-addressed store, hash-verified

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

Calls 13

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