huggingface

package
v3.82.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

View Source
const (
	FINEGRAINED = "fineGrained"
	WRITE       = "write"
	READ        = "read"
)

Variables

View Source
var (
	PermissionStrings = map[Permission]string{
		Read:  "read",
		Write: "write",
	}

	StringToPermission = map[string]Permission{
		"read":  Read,
		"write": Write,
	}

	PermissionIDs = map[Permission]int{
		Read:  1,
		Write: 2,
	}

	IdToPermission = map[int]Permission{
		1: Read,
		2: Write,
	}
)

Functions

func AnalyzeAndPrintPermissions added in v3.80.5

func AnalyzeAndPrintPermissions(cfg *config.Config, key string)

AnalyzePermissions prints the permissions of a HuggingFace API key

Types

type Analyzer added in v3.80.5

type Analyzer struct {
	Cfg *config.Config
}

func (Analyzer) Analyze added in v3.80.5

func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error)

func (Analyzer) Type added in v3.80.5

type HFTokenJSON

type HFTokenJSON struct {
	Username string `json:"name"`
	Name     string `json:"fullname"`
	Orgs     []struct {
		Name         string `json:"name"`
		Role         string `json:"roleInOrg"`
		IsEnterprise bool   `json:"isEnterprise"`
	} `json:"orgs"`
	Auth struct {
		AccessToken struct {
			Name        string `json:"displayName"`
			Type        string `json:"role"`
			CreatedAt   string `json:"createdAt"`
			FineGrained struct {
				Global []string `json:"global"`
				Scoped []struct {
					Entity struct {
						Type string `json:"type"`
						Name string `json:"name"`
						ID   string `json:"_id"`
					} `json:"entity"`
					Permissions []string `json:"permissions"`
				} `json:"scoped"`
			} `json:"fineGrained"`
		}
	} `json:"auth"`
}

HFTokenJSON is the struct for the HF /whoami-v2 API JSON response

type Model

type Model struct {
	Name        string `json:"id"`
	ID          string `json:"_id"`
	Private     bool   `json:"private"`
	Permissions Permissions
}

type Permission added in v3.82.3

type Permission int
const (
	Invalid Permission = iota
	Read    Permission = iota
	Write   Permission = iota
)

func PermissionFromID added in v3.82.3

func PermissionFromID(id int) (Permission, error)

PermissionFromID converts an ID to its Permission enum

func PermissionFromString added in v3.82.3

func PermissionFromString(s string) (Permission, error)

PermissionFromString converts a string representation to its Permission enum

func (Permission) ToID added in v3.82.3

func (p Permission) ToID() (int, error)

ToID converts a Permission enum to its ID

func (Permission) ToString added in v3.82.3

func (p Permission) ToString() (string, error)

ToString converts a Permission enum to its string representation

type Permissions

type Permissions struct {
	Read  bool
	Write bool
}

type SecretInfo added in v3.80.5

type SecretInfo struct {
	Token  HFTokenJSON
	Models []Model
}

func AnalyzePermissions

func AnalyzePermissions(cfg *config.Config, key string) (*SecretInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL