setup

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPorts = []int{30000, 8000, 11434, 8080, 5000, 8001}

Common inference server ports to scan

Functions

func DetectModelCategory

func DetectModelCategory(modelName string) string

DetectModelCategory tries to detect the model category from its name

func EstimateGPUMemory

func EstimateGPUMemory(modelName string) int

EstimateGPUMemory estimates GPU memory needed for a model based on its name

func MaskApiKey

func MaskApiKey(apiKey string) string

MaskApiKey returns a masked version of the API key for display

func PrintBullet

func PrintBullet(msg string)

PrintBullet prints a bullet point

func PrintError

func PrintError(msg string)

PrintError prints an error message

func PrintHeader

func PrintHeader(title string)

PrintHeader prints a styled header

func PrintInfo

func PrintInfo(msg string)

PrintInfo prints an info message

func PrintKeyValue

func PrintKeyValue(key, value string)

PrintKeyValue prints a key-value pair

func PrintStep

func PrintStep(step, total int, title string)

PrintStep prints a step header

func PrintSuccess

func PrintSuccess(msg string)

PrintSuccess prints a success message

func PrintWarning

func PrintWarning(msg string)

PrintWarning prints a warning message

func ValidateEVMAddress

func ValidateEVMAddress(addr string) error

ValidateEVMAddress validates an EVM wallet address format - Must be 42 characters - Must start with "0x" - Remaining 40 chars must be valid hex

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail validates an email address (simplified RFC 5322)

func ValidateName

func ValidateName(name string) error

ValidateName validates a node/provider name (1-64 chars, alphanumeric + hyphens/underscores)

func ValidatePassword

func ValidatePassword(password string) error

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

type PrerequisiteResult struct {
	Name    string
	Status  bool
	Version string
	Message string
}

PrerequisiteResult represents the result of a prerequisite check

type Prompter

type Prompter struct {
	// contains filtered or unexported fields
}

Prompter handles interactive CLI prompts

func NewPrompter

func NewPrompter() *Prompter

NewPrompter creates a new prompter

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

func (p *Prompter) AskPassword(prompt string) (string, error)

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

func (*Prompter) AskString

func (p *Prompter) AskString(prompt string, defaultValue string) (string, error)

AskString prompts for a string input

func (*Prompter) AskYesNo

func (p *Prompter) AskYesNo(prompt string, defaultYes bool) (bool, error)

AskYesNo prompts for a yes/no answer

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

type SelectionOption struct {
	Label       string
	Description string
	Value       interface{}
}

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

func FetchSwanModels(apiURL string) ([]SwanModel, error)

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

type UserLoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

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

Jump to

Keyboard shortcuts

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