Documentation ¶
Index ¶
- Constants
- func GetAPIToken() string
- func GetAPITokenMask() string
- func SetAPIToken(token string)
- type CivitaiClient
- type CivitaiClientOption
- type ConsoleCell
- type ConsoleTable
- type ErrorResponse
- type FileDownloadOption
- type FormatModelInfoOption
- type FormatModelVersionOption
- type ModelCreator
- type ModelHashes
- type ModelInfo
- type ModelInfoFiles
- type ModelInfoImages
- type ModelInfoVersions
- type ModelMetadata
- type ModelStats
- type ModelVersion
- type ModelVersionFiles
- type ModelVersionImages
- type ModelVersionModel
- type ModelVersionStats
- type Output
- type Terminal
- type TerminalTable
Constants ¶
View Source
const ( URLModelInfoByID = "/v1/models/%s" URLModelVersionInfoByID = "/v1/model-versions/%s" )
View Source
const ( CivitaiAPIBaseV1 = "https://civitai.com/api/" UserAgent = "civitai-go-client (https://github.com/zhaolion/civitai-cli)" )
View Source
const ( ModelTypeCheckpoint = "Checkpoint" ModelTypeTextualInversion = "TextualInversion" ModelTypeHypernetwork = "Hypernetwork" ModelTypeAestheticGradient = "AestheticGradient" ModelTypeLORA = "LORA" ModelTypeControlnet = "Controlnet" ModelTypePoses = "Poses" )
View Source
const ( TokenEnvKey = "CIVITAI_API_KEY" ConfigDir = "~/.civitai" TokenFilePath = "~/.civitai/token" )
Variables ¶
This section is empty.
Functions ¶
func GetAPIToken ¶
func GetAPIToken() string
func GetAPITokenMask ¶
func GetAPITokenMask() string
func SetAPIToken ¶
func SetAPIToken(token string)
Types ¶
type CivitaiClient ¶
type CivitaiClient struct { *req.Client // contains filtered or unexported fields }
func NewClient ¶
func NewClient(token string, opts ...CivitaiClientOption) *CivitaiClient
NewClient with an API Key you can authenticate
func (*CivitaiClient) FileDownload ¶
func (c *CivitaiClient) FileDownload(ctx context.Context, file *ModelInfoFiles, targetFile string, opts ...*FileDownloadOption) error
FileDownload download file from fileURL to targetFile.
func (*CivitaiClient) ModelInfoByID ¶
func (c *CivitaiClient) ModelInfoByID(modelID string) (*ModelInfo, error)
ModelInfoByID fetch model info by id. GET /api/v1/models/:modelId API Doc: https://developer.civitai.com/docs/api/public-rest#get-apiv1modelsmodelid
func (*CivitaiClient) ModelVersionByID ¶
func (c *CivitaiClient) ModelVersionByID(verID string) (*ModelVersion, error)
ModelVersionByID fetch model version files by ver-id. GET /api/v1/models/:modelId API Doc: https://developer.civitai.com/docs/api/public-rest#get-apiv1modelsmodelid
type CivitaiClientOption ¶
type CivitaiClientOption func(cli *CivitaiClient)
func CivitaiClientOptionDebug ¶
func CivitaiClientOptionDebug(enable bool) CivitaiClientOption
type ConsoleCell ¶
type ConsoleTable ¶
type ConsoleTable struct {
Cells [][]*ConsoleCell `json:"cells,omitempty"`
}
func NewConsoleTable ¶
func NewConsoleTable() *ConsoleTable
type ErrorResponse ¶
func NewNotFoundError ¶
func NewNotFoundError(apiType, id string) *ErrorResponse
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type FileDownloadOption ¶
type FileDownloadOption struct { DownloadTimeoutSec uint32 Callback req.DownloadCallback }
type FormatModelInfoOption ¶
type FormatModelInfoOption struct {
Full bool
}
type FormatModelVersionOption ¶
type FormatModelVersionOption struct {
Full bool
}
type ModelCreator ¶
type ModelHashes ¶
type ModelInfo ¶
type ModelInfo struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` AllowNoCredit bool `json:"allowNoCredit,omitempty"` AllowCommercialUse []string `json:"allowCommercialUse,omitempty"` AllowDerivatives bool `json:"allowDerivatives,omitempty"` AllowDifferentLicense bool `json:"allowDifferentLicense,omitempty"` Type string `json:"type,omitempty"` Minor bool `json:"minor,omitempty"` Poi bool `json:"poi,omitempty"` Nsfw bool `json:"nsfw,omitempty"` NsfwLevel int `json:"nsfwLevel,omitempty"` Cosmetic interface{} `json:"cosmetic,omitempty"` Stats ModelStats `json:"stats,omitempty"` Creator ModelCreator `json:"creator,omitempty"` Tags []string `json:"tags,omitempty"` ModelVersions []ModelInfoVersions `json:"modelVersions,omitempty"` }
func (*ModelInfo) MatchVerByID ¶
func (m *ModelInfo) MatchVerByID(verID string) *ModelInfoVersions
type ModelInfoFiles ¶
type ModelInfoFiles struct { ID int `json:"id,omitempty"` SizeKB float64 `json:"sizeKB,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` PickleScanResult string `json:"pickleScanResult,omitempty"` PickleScanMessage string `json:"pickleScanMessage,omitempty"` VirusScanResult string `json:"virusScanResult,omitempty"` VirusScanMessage interface{} `json:"virusScanMessage,omitempty"` ScannedAt time.Time `json:"scannedAt,omitempty"` Metadata ModelMetadata `json:"metadata,omitempty"` Hashes ModelHashes `json:"hashes,omitempty"` DownloadURL string `json:"downloadUrl,omitempty"` Primary bool `json:"primary,omitempty"` }
type ModelInfoImages ¶
type ModelInfoVersions ¶
type ModelInfoVersions struct { ID int `json:"id,omitempty"` Index int `json:"index,omitempty"` Name string `json:"name,omitempty"` BaseModel string `json:"baseModel,omitempty"` BaseModelType string `json:"baseModelType,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` PublishedAt time.Time `json:"publishedAt,omitempty"` Status string `json:"status,omitempty"` Availability string `json:"availability,omitempty"` NsfwLevel int `json:"nsfwLevel,omitempty"` Description string `json:"description,omitempty"` TrainedWords []string `json:"trainedWords,omitempty"` Stats ModelStats `json:"stats,omitempty"` Files []ModelInfoFiles `json:"files,omitempty"` Images []ModelInfoImages `json:"images,omitempty"` DownloadURL string `json:"downloadUrl,omitempty"` }
type ModelMetadata ¶
type ModelStats ¶
type ModelStats struct { DownloadCount int `json:"downloadCount,omitempty"` // version 公共字段 - begin RatingCount int `json:"ratingCount,omitempty"` Rating float64 `json:"rating,omitempty"` ThumbsUpCount int `json:"thumbsUpCount,omitempty"` ThumbsDownCount int `json:"thumbsDownCount,omitempty"` // version 公共字段 - end FavoriteCount int `json:"favoriteCount,omitempty"` CommentCount int `json:"commentCount,omitempty"` TippedAmountCount int `json:"tippedAmountCount,omitempty"` }
type ModelVersion ¶
type ModelVersion struct { ID int `json:"id,omitempty"` ModelID int `json:"modelId,omitempty"` Name string `json:"name,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` TrainedWords []string `json:"trainedWords,omitempty"` BaseModel string `json:"baseModel,omitempty"` EarlyAccessTimeFrame int `json:"earlyAccessTimeFrame,omitempty"` Description interface{} `json:"description,omitempty"` // Stats only contains: // DownloadCount int // RatingCount int // Rating int Stats ModelStats `json:"stats,omitempty"` Model ModelVersionModel `json:"model,omitempty"` Files []ModelVersionFiles `json:"files,omitempty"` Images []ModelVersionImages `json:"images,omitempty"` DownloadURL string `json:"downloadUrl,omitempty"` }
func (*ModelVersion) JSON ¶
func (m *ModelVersion) JSON() string
type ModelVersionFiles ¶
type ModelVersionFiles struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` SizeKB float64 `json:"sizeKB,omitempty"` Type string `json:"type,omitempty"` Metadata ModelMetadata `json:"metadata,omitempty"` PickleScanResult string `json:"pickleScanResult,omitempty"` PickleScanMessage string `json:"pickleScanMessage,omitempty"` VirusScanResult string `json:"virusScanResult,omitempty"` ScannedAt time.Time `json:"scannedAt,omitempty"` Hashes ModelHashes `json:"hashes,omitempty"` Primary bool `json:"primary,omitempty"` DownloadURL string `json:"downloadUrl,omitempty"` }
type ModelVersionImages ¶
type ModelVersionModel ¶
type ModelVersionStats ¶
type Output ¶
type Output interface {
Format(ctx context.Context, table *ConsoleTable) ([]byte, error)
}
type Terminal ¶
type Terminal struct {
Output
}
func NewTerminal ¶
func NewTerminal() *Terminal
func (*Terminal) PrintModelInfo ¶
func (terminal *Terminal) PrintModelInfo(ctx context.Context, m *ModelInfo, _ *FormatModelInfoOption) error
PrintModelInfo print model info into terminal.
func (*Terminal) PrintModelVersionByID ¶
func (terminal *Terminal) PrintModelVersionByID(ctx context.Context, m *ModelVersion, _ *FormatModelVersionOption) error
type TerminalTable ¶
type TerminalTable struct {
Style string
}
func NewTerminalTable ¶
func NewTerminalTable() *TerminalTable
func (*TerminalTable) Format ¶
func (out *TerminalTable) Format(_ context.Context, input *ConsoleTable) ([]byte, error)
Click to show internal directories.
Click to hide internal directories.