aiservice

package
v0.0.0-...-10fbe9a Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIService

type AIService struct {
	Config
	// contains filtered or unexported fields
}

func New

func New() *AIService

func (*AIService) Init

func (s *AIService) Init() (*AIService, error)

Init 加载配置并初始化

func (*AIService) SetClaudeCode

func (s *AIService) SetClaudeCode(opts SetClaudeCodeParam) error

SetClaudeCode 设置 cc 的 API url 和令牌信息

func (*AIService) ShowConfig

func (s *AIService) ShowConfig(keyName string)

type APIProvider

type APIProvider struct {
	BaseURL string `json:"base_url" yaml:"base_url"`
	APIKey  string `json:"api_key" yaml:"api_key"`
}

type AgentToolInfo

type AgentToolInfo struct {
	// 环境变量 需要设置到 cc config
	Envs map[string]string `yaml:"envs"`
}

AgentToolInfo agent tool config

type CCProviderConfig

type CCProviderConfig struct {
	ProviderConfig `yaml:",squash"`
	// 配置到 cc config 的模型代码
	ModelCode string `json:"model_code" yaml:"model_code"`
	// 环境变量 需要设置到 cc config
	Envs map[string]string `yaml:"envs"`
	// API 提供者 key 是提供者名称
	APIProviders map[string]*APIProvider `yaml:"api_providers"`
}

CCProviderConfig holds the configuration for a single CC provider

func (*CCProviderConfig) GetEnvMaps

func (p *CCProviderConfig) GetEnvMaps(keyName, model string) map[string]string

GetEnvMaps returns the environment variables for the provider

type Config

type Config struct {
	// 默认的模型提供者
	DefaultProvider string `json:"default_provider" yaml:"default_provider"`
	// 默认的模型名称
	DefaultModel string `json:"default_model" yaml:"default_model"`
	// 支持的模型提供者列表(API场景使用)
	Providers map[string]*ProviderConfig `json:"providers" yaml:"providers"`
	// 提供者别名映射
	ProviderAliases map[string]string `json:"provider_aliases" yaml:"provider_aliases"`
	// 模型别名映射
	ModelAliases map[string]string `json:"model_aliases" yaml:"model_aliases"`
	// 不同场景使用的模型映射
	SceneModels map[string]string `json:"scene_models" yaml:"scene_models"`
	// key is tool name, eg: claude_code, codex, gemini
	AgentTools map[string]*AgentToolInfo `json:"agent_tools" yaml:"agent_tools"`
	// Claude-code 专用的提供者列表
	CcProviders map[string]*CCProviderConfig `json:"cc_providers" yaml:"cc_providers"`
}

Config holds the configuration for the AI service

func (*Config) CCProviderConfig

func (c *Config) CCProviderConfig(name string) (*CCProviderConfig, error)

CCProviderConfig holds the configuration for a single CC provider

func (*Config) CCProviderNames

func (c *Config) CCProviderNames() []string

CCProviderNames returns a list of all available CC provider names

func (*Config) Init

func (c *Config) Init() error

Init 初始化 config 部分信息

func (*Config) IsCCProvider

func (c *Config) IsCCProvider(name string) bool

IsCCProvider checks if a given name is a valid CC provider

func (*Config) IsProvider

func (c *Config) IsProvider(name string) bool

IsProvider checks if a given name is a valid provider

func (*Config) ModelName

func (c *Config) ModelName(name string) string

ModelName returns the real name of a model

func (*Config) ProviderConfig

func (c *Config) ProviderConfig(name string) (*ProviderConfig, error)

ProviderConfig holds the configuration for a single AI provider

func (*Config) ProviderName

func (c *Config) ProviderName(name string) string

ProviderName returns the real name of a provider

func (*Config) ProviderNames

func (c *Config) ProviderNames() []string

ProviderNames returns a list of all available provider names

type ProviderConfig

type ProviderConfig struct {
	Name        string   `json:"name" yaml:"name"`
	BaseURL     string   `json:"base_url" yaml:"base_url"`
	APIKey      string   `json:"api_key" yaml:"api_key"` // api key, api token
	Description string   `json:"description" yaml:"description"`
	Aliases     []string `json:"aliases" yaml:"aliases"`
	// 可用模型列表
	Models   []string `json:"models" yaml:"models"`
	DocsURL  string   `json:"docs_url" yaml:"docs_url"`
	Homepage string   `json:"homepage" yaml:"homepage"`
}

ProviderConfig holds the configuration for a single AI provider

type SetClaudeCodeParam

type SetClaudeCodeParam struct {
	Provider string
	KeyName  string // api key name
	Model    string // 指定模型名称
	Scope    string // 作用域 user, project
	Shell    string
	Write    bool
	Show     bool
	List     bool
}

SetClaudeCodeParam 参数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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