Documentation
¶
Index ¶
- Variables
- func DetectModelCategory(modelName string) string
- func EstimateGPUMemory(modelName string) int
- func MaskApiKey(apiKey string) string
- func PrintBullet(msg string)
- func PrintError(msg string)
- func PrintHeader(title string)
- func PrintInfo(msg string)
- func PrintKeyValue(key, value string)
- func PrintStep(step, total int, title string)
- func PrintSuccess(msg string)
- func PrintWarning(msg string)
- func ValidateEVMAddress(addr string) error
- func ValidateEmail(email string) error
- func ValidateName(name string) error
- func ValidatePassword(password string) error
- type AuthClient
- func (c *AuthClient) CreateProviderKey(userToken, keyName string) (*CreateProviderKeyResponse, error)
- func (c *AuthClient) GetProviderStatus(apiKey string) (*ProviderStatusResponse, error)
- func (c *AuthClient) Login(email, password string) (*UserLoginResponse, error)
- func (c *AuthClient) Signup(email, password, displayName string) (*UserSignupResponse, error)
- func (c *AuthClient) UpgradeToProvider(token, name, walletAddress string) (*UpgradeToProviderResponse, error)
- func (c *AuthClient) ValidateApiKey(apiKey string) (bool, error)
- type CreateProviderKeyRequest
- type CreateProviderKeyResponse
- type Credentials
- type CredentialsManager
- type DiscoveredServer
- type ModelDiscovery
- type ModelInfo
- type ModelMatch
- type PrerequisiteChecker
- type PrerequisiteResult
- type Prompter
- func (p *Prompter) AskMultiSelect(prompt string, options []SelectionOption) ([]int, error)
- func (p *Prompter) AskPassword(prompt string) (string, error)
- func (p *Prompter) AskSelection(prompt string, options []SelectionOption) (int, error)
- func (p *Prompter) AskString(prompt string, defaultValue string) (string, error)
- func (p *Prompter) AskYesNo(prompt string, defaultYes bool) (bool, error)
- type ProviderStatusResponse
- type SelectionOption
- type ServerType
- type SwanModel
- type UpgradeToProviderRequest
- type UpgradeToProviderResponse
- type UserLoginRequest
- type UserLoginResponse
- type UserPublicInfo
- type UserSignupRequest
- type UserSignupResponse
Constants ¶
This section is empty.
Variables ¶
var DefaultPorts = []int{30000, 8000, 11434, 8080, 5000, 8001}
Common inference server ports to scan
Functions ¶
func DetectModelCategory ¶
DetectModelCategory tries to detect the model category from its name
func EstimateGPUMemory ¶
EstimateGPUMemory estimates GPU memory needed for a model based on its name
func MaskApiKey ¶
MaskApiKey returns a masked version of the API key for display
func ValidateEVMAddress ¶
ValidateEVMAddress validates an EVM wallet address format - Must be 42 characters - Must start with "0x" - Remaining 40 chars must be valid hex
func ValidateEmail ¶
ValidateEmail validates an email address (simplified RFC 5322)
func ValidateName ¶
ValidateName validates a node/provider name (1-64 chars, alphanumeric + hyphens/underscores)
func ValidatePassword ¶
ValidatePassword validates a password (minimum 8 characters)
Types ¶
type AuthClient ¶
type AuthClient struct {
// contains filtered or unexported fields
}
AuthClient handles authentication with Swan Inference API
func NewAuthClient ¶
func NewAuthClient(baseURL string) *AuthClient
NewAuthClient creates a new auth client
func (*AuthClient) CreateProviderKey ¶
func (c *AuthClient) CreateProviderKey(userToken, keyName string) (*CreateProviderKeyResponse, error)
CreateProviderKey creates a new provider API key using user JWT token This is used for existing providers who need a new API key
func (*AuthClient) GetProviderStatus ¶
func (c *AuthClient) GetProviderStatus(apiKey string) (*ProviderStatusResponse, error)
GetProviderStatus retrieves provider status using an API key
func (*AuthClient) Login ¶
func (c *AuthClient) Login(email, password string) (*UserLoginResponse, error)
Login authenticates a user with email and password
func (*AuthClient) Signup ¶
func (c *AuthClient) Signup(email, password, displayName string) (*UserSignupResponse, error)
Signup creates a new user account
func (*AuthClient) UpgradeToProvider ¶
func (c *AuthClient) UpgradeToProvider(token, name, walletAddress string) (*UpgradeToProviderResponse, error)
UpgradeToProvider upgrades a user account to a provider
func (*AuthClient) ValidateApiKey ¶
func (c *AuthClient) ValidateApiKey(apiKey string) (bool, error)
ValidateApiKey validates an existing API key by checking provider status
type CreateProviderKeyRequest ¶
type CreateProviderKeyRequest struct {
Name string `json:"name"`
}
CreateProviderKeyRequest represents a request to create a new provider key
type CreateProviderKeyResponse ¶
type CreateProviderKeyResponse struct {
ApiKey string `json:"api_key"`
ProviderID string `json:"provider_id"`
Message string `json:"message"`
Error string `json:"error,omitempty"`
}
CreateProviderKeyResponse represents the response from creating a provider key
type Credentials ¶
type Credentials struct {
ApiKey string `json:"api_key"`
Email string `json:"email,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
Name string `json:"name,omitempty"`
}
Credentials represents stored credentials
type CredentialsManager ¶
type CredentialsManager struct {
// contains filtered or unexported fields
}
CredentialsManager handles credential storage
func NewCredentialsManager ¶
func NewCredentialsManager(cpPath string) *CredentialsManager
NewCredentialsManager creates a new credentials manager
func (*CredentialsManager) GetApiKey ¶
func (m *CredentialsManager) GetApiKey() string
GetApiKey returns the stored API key
func (*CredentialsManager) Load ¶
func (m *CredentialsManager) Load() (*Credentials, error)
Load loads credentials from file
func (*CredentialsManager) Save ¶
func (m *CredentialsManager) Save(creds *Credentials) error
Save saves credentials to file with restricted permissions
type DiscoveredServer ¶
type DiscoveredServer struct {
Host string `json:"host"`
Port int `json:"port"`
Type ServerType `json:"type"`
Models []string `json:"models"`
Healthy bool `json:"healthy"`
Endpoint string `json:"endpoint"`
RawModels []ModelInfo `json:"raw_models,omitempty"`
}
DiscoveredServer represents a discovered inference server
type ModelDiscovery ¶
type ModelDiscovery struct {
// contains filtered or unexported fields
}
ModelDiscovery handles auto-discovery of model servers
func NewModelDiscovery ¶
func NewModelDiscovery() *ModelDiscovery
NewModelDiscovery creates a new model discovery instance
func (*ModelDiscovery) DiscoverAll ¶
func (d *ModelDiscovery) DiscoverAll() []DiscoveredServer
DiscoverAll scans all default ports and returns discovered servers
func (*ModelDiscovery) DiscoverOnPorts ¶
func (d *ModelDiscovery) DiscoverOnPorts(host string, ports []int) []DiscoveredServer
DiscoverOnPorts scans specified ports on a host
type ModelInfo ¶
type ModelInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
}
ModelInfo represents information about a model
type ModelMatch ¶
type ModelMatch struct {
LocalModel string // Original local model name (e.g., "llama3.2:3b")
SwanModelID string // Swan Inference model ID (e.g., "llama-3.2-3b")
SwanModelName string // Human-readable name
Confidence float64 // Match confidence (0-1)
}
ModelMatch represents a match between a local model and Swan Inference model
func MatchModels ¶
func MatchModels(localModels []string, swanModels []SwanModel) []ModelMatch
MatchModels matches local models to Swan Inference models
type PrerequisiteChecker ¶
type PrerequisiteChecker struct {
// contains filtered or unexported fields
}
PrerequisiteChecker handles system prerequisite checks
func NewPrerequisiteChecker ¶
func NewPrerequisiteChecker() *PrerequisiteChecker
NewPrerequisiteChecker creates a new prerequisite checker
func (*PrerequisiteChecker) CheckAll ¶
func (pc *PrerequisiteChecker) CheckAll() []PrerequisiteResult
CheckAll runs all prerequisite checks
func (*PrerequisiteChecker) HasCriticalFailures ¶
func (pc *PrerequisiteChecker) HasCriticalFailures() bool
HasCriticalFailures returns true if any critical prerequisite failed For Inference mode: need Docker OR Ollama (not both)
type PrerequisiteResult ¶
PrerequisiteResult represents the result of a prerequisite check
type Prompter ¶
type Prompter struct {
// contains filtered or unexported fields
}
Prompter handles interactive CLI prompts
func (*Prompter) AskMultiSelect ¶
func (p *Prompter) AskMultiSelect(prompt string, options []SelectionOption) ([]int, error)
AskMultiSelect prompts user to select multiple options from a list Defaults to "all" if user presses Enter without input
func (*Prompter) AskPassword ¶
AskPassword prompts for a password (hidden input)
func (*Prompter) AskSelection ¶
func (p *Prompter) AskSelection(prompt string, options []SelectionOption) (int, error)
AskSelection prompts user to select one option from a list
type ProviderStatusResponse ¶
type ProviderStatusResponse struct {
ProviderID string `json:"provider_id"`
Name string `json:"name"`
Status string `json:"status"`
CanConnect bool `json:"can_connect"`
ApiKeyValid bool `json:"api_key_valid"`
Message string `json:"message"`
NextSteps []string `json:"next_steps"`
Error string `json:"error,omitempty"`
}
ProviderStatusResponse represents the provider status response
type SelectionOption ¶
SelectionOption represents a selection option
type ServerType ¶
type ServerType string
ServerType represents the type of inference server
const ( ServerTypeSGLang ServerType = "sglang" ServerTypeVLLM ServerType = "vllm" ServerTypeOllama ServerType = "ollama" ServerTypeOpenAI ServerType = "openai-compatible" ServerTypeUnknown ServerType = "unknown" )
type SwanModel ¶
type SwanModel struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Category string `json:"category"`
Active bool `json:"active"`
}
SwanModel represents a model from Swan Inference API
func FetchSwanModels ¶
FetchSwanModels fetches the list of supported models from Swan Inference API
type UpgradeToProviderRequest ¶
type UpgradeToProviderRequest struct {
Name string `json:"name"`
WalletAddress string `json:"wallet_address"`
WorkerAddress string `json:"worker_address,omitempty"`
BeneficiaryAddress string `json:"beneficiary_address,omitempty"`
Description string `json:"description,omitempty"`
}
UpgradeToProviderRequest represents the upgrade to provider request
type UpgradeToProviderResponse ¶
type UpgradeToProviderResponse struct {
ProviderID string `json:"provider_id"`
ProviderApiKey string `json:"provider_api_key"`
ProviderKeyPrefix string `json:"provider_key_prefix"`
Status string `json:"status"`
CanConnect bool `json:"can_connect"`
Message string `json:"message"`
NextSteps []string `json:"next_steps"`
Error string `json:"error,omitempty"`
}
UpgradeToProviderResponse represents the upgrade to provider response
type UserLoginRequest ¶
UserLoginRequest represents the user login request
type UserLoginResponse ¶
type UserLoginResponse struct {
User *UserPublicInfo `json:"user"`
Token string `json:"token"`
Error string `json:"error,omitempty"`
}
UserLoginResponse represents the user login response
type UserPublicInfo ¶
type UserPublicInfo struct {
ID string `json:"id"`
Email string `json:"email"`
DisplayName string `json:"display_name"`
AccountType string `json:"account_type"` // "consumer" or "provider"
ProviderID string `json:"provider_id,omitempty"`
}
UserPublicInfo represents public user information
type UserSignupRequest ¶
type UserSignupRequest struct {
Email string `json:"email"`
Password string `json:"password"`
DisplayName string `json:"display_name"`
}
UserSignupRequest represents the user signup request
type UserSignupResponse ¶
type UserSignupResponse struct {
Token string `json:"token"`
User *UserPublicInfo `json:"user"`
ApiKey string `json:"api_key,omitempty"`
Error string `json:"error,omitempty"`
}
UserSignupResponse represents the user signup response