setup

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

internal/setup/setup.go

Index

Constants

This section is empty.

Variables

View Source
var BuiltinProviders = []ProviderInfo{
	{
		ID:          "anthropic",
		Name:        "Anthropic (Claude)",
		Description: "Claude 系列模型,推荐",
		BaseURL:     "",
		EnvKey:      "ANTHROPIC_API_KEY",
		Models: []string{
			"claude-sonnet-4-6-20250514",
			"claude-opus-4-6-20250610",
			"claude-haiku-4-5-20251001",
		},
	},
	{
		ID:          "openai",
		Name:        "OpenAI",
		Description: "GPT / o 系列模型",
		BaseURL:     "",
		EnvKey:      "OPENAI_API_KEY",
		Models: []string{
			"gpt-4.1",
			"o4-mini",
			"o3",
		},
	},
	{
		ID:          "openrouter",
		Name:        "OpenRouter",
		Description: "多模型聚合,支持数百个模型",
		BaseURL:     "https://openrouter.ai/api/v1",
		EnvKey:      "OPENROUTER_API_KEY",
		Models: []string{
			"anthropic/claude-sonnet-4-6",
			"openai/gpt-4.1",
			"google/gemini-2.5-pro",
		},
	},
	{
		ID:          "custom",
		Name:        "自定义端点",
		Description: "兼容 OpenAI API 的自定义服务",
		BaseURL:     "",
		EnvKey:      "",
		Models:      []string{},
	},
}

BuiltinProviders 预置 Provider 列表

Functions

func SaveGlobalSettings

func SaveGlobalSettings(path string, fields map[string]string) error

SaveGlobalSettings 写入/合并全局设置到 settings.json fields 是需要更新的 key-value 对

Types

type Model

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

Model Setup TUI Model

func New

func New(configDir string) Model

New 创建 Setup TUI

func (Model) GetResult

func (m Model) GetResult() (Result, error)

GetResult 获取 Setup 结果

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type ProviderInfo

type ProviderInfo struct {
	ID          string   // "anthropic", "openai", "openrouter", "custom"
	Name        string   // 显示名
	Description string   // 一句话描述
	BaseURL     string   // 默认 API 端点(custom 为空)
	EnvKey      string   // 对应的环境变量名
	Models      []string // 推荐模型列表(首个为默认)
}

ProviderInfo 预置 Provider 信息

type Result

type Result struct {
	Provider string
	APIKey   string
	BaseURL  string
	Model    string
}

Result Setup 完成后的结果

type SetupStep

type SetupStep int

SetupStep 引导步骤

const (
	StepProvider SetupStep = iota // 选择 Provider
	StepAPIKey                    // 输入 API Key
	StepBaseURL                   // 输入自定义 BaseURL(仅 custom provider)
	StepModel                     // 选择模型
	StepConfirm                   // 确认并保存
	StepDone                      // 完成
)

Jump to

Keyboard shortcuts

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