conf

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(cpPath string) bool

func GenerateAndUpdateConfigFile

func GenerateAndUpdateConfigFile(cpRepoPath string, multiAddress, nodeName string, port int) error

func GetInferenceApiKey

func GetInferenceApiKey(cpRepoPath string) string

GetInferenceApiKey returns the configured Inference API key It first checks the environment variable, then the config file

func GetRpcByNetWorkName

func GetRpcByNetWorkName() (string, error)

func InitConfig

func InitConfig(cpRepoPath string, standalone bool) error

func LoadModelsJson

func LoadModelsJson(cpRepoPath string) (map[string]ModelConfig, error)

LoadModelsJson loads the models.json file

func UpdateInferenceConfig

func UpdateInferenceConfig(cpRepoPath, apiKey string, models []string) error

UpdateInferenceConfig updates the Inference section in config.toml

func WriteModelsJson

func WriteModelsJson(cpRepoPath string, models map[string]ModelConfig) error

WriteModelsJson writes the models.json file from model configurations

Types

type API

type API struct {
	Port                          int
	MultiAddress                  string
	Domain                        string
	NodeName                      string
	WalletWhiteList               string
	WalletBlackList               string
	Pricing                       Pricing  `toml:"pricing"`
	AutoDeleteImage               bool     `toml:"AutoDeleteImage"`
	ClearLogDuration              int      `toml:"ClearLogDuration"`
	PortRange                     []string `toml:"PortRange"`
	GpuUtilizationRejectThreshold float64  `toml:"GpuUtilizationRejectThreshold"`
}

type CONTRACT

type CONTRACT struct {
	UpgradeName       string
	SwanToken         string `toml:"SWAN_CONTRACT"`
	CpAccountRegister string `toml:"REGISTER_CP_CONTRACT"`

	JobCollateral     string `toml:"SWAN_COLLATERAL_CONTRACT"`
	JobManager        string `toml:"SWAN_JOB_CONTRACT"`
	JobManagerCreated uint64 `toml:"JobManagerCreated"`

	TaskRegister           string `toml:"REGISTER_TASK_CONTRACT"`
	ZkCollateral           string `toml:"ZK_COLLATERAL_CONTRACT"`
	Sequencer              string `toml:"SEQUENCER_CONTRACT"`
	EdgeTaskPayment        string `toml:"EDGE_TASK_PAYMENT"`
	EdgeTaskPaymentCreated uint64 `toml:"EdgeTaskPaymentCreated"`

	JobCollateralUbiZero string `toml:"SWAN_COLLATERAL_UBI_ZERO_CONTRACT"`
	ZkCollateralUbiZero  string `toml:"ZK_COLLATERAL_UBI_ZERO_CONTRACT"`
}

type ComputeNode

type ComputeNode struct {
	API       API
	UBI       UBI
	LOG       LOG
	Registry  Registry
	RPC       RPC
	CONTRACT  CONTRACT  `toml:"CONTRACT,omitempty"`
	Inference Inference `toml:"Inference,omitempty"`
}

ComputeNode is a compute node config

func GetConfig

func GetConfig() *ComputeNode

type Inference

type Inference struct {
	Enable             bool     `toml:"Enable"`
	ServiceURL         string   `toml:"ServiceURL"`         // HTTP API URL (e.g., http://localhost:8080)
	WebSocketURL       string   `toml:"WebSocketURL"`       // WebSocket URL (e.g., wss://inference-ws.swanchain.io)
	ApiKey             string   `toml:"ApiKey"`             // Provider API key for authentication (sk-prov-*)
	Models             []string `toml:"Models"`             // Models this provider serves
	ChainRPC           string   `toml:"ChainRPC"`           // Base Sepolia RPC for Swan Inference
	CollateralContract string   `toml:"CollateralContract"` // Collateral contract address
	TaskContract       string   `toml:"TaskContract"`       // Task contract address
}

Inference is the Swan Inference marketplace configuration (default mode)

type LOG

type LOG struct {
	CrtFile string
	KeyFile string
}

type ModelConfig

type ModelConfig struct {
	Container  string `json:"container,omitempty"`
	Endpoint   string `json:"endpoint"`
	GPUMemory  int    `json:"gpu_memory"`
	Category   string `json:"category"`
	LocalModel string `json:"local_model,omitempty"` // Actual model name to use in requests (e.g., Ollama model name)
}

ModelConfig represents a model configuration for models.json

type Pricing

type Pricing bool

func (*Pricing) UnmarshalTOML

func (p *Pricing) UnmarshalTOML(data interface{}) error

type RPC

type RPC struct {
	SwanChainRpc string `toml:"SWAN_CHAIN_RPC"`
}

type Registry

type Registry struct {
	ServerAddress string
	UserName      string
	Password      string
}

type UBI

type UBI struct {
	UbiEnginePk     string
	EnableSequencer bool
	AutoChainProof  bool
	SequencerUrl    string
	EdgeUrl         string
	VerifySign      bool
}

Jump to

Keyboard shortcuts

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