diff --git a/README.zh.md b/README.zh.md index 5d3af50ca..5e90f2b3a 100644 --- a/README.zh.md +++ b/README.zh.md @@ -748,3 +748,4 @@ Discord: [https://discord.gg/V4sAZ9XWpN](https://discord.gg/V4sAZ9XWpN) | **智谱 (Zhipu)** | 200K tokens/月 | 最适合中国用户 | | **Brave Search** | 2000 次查询/月 | 网络搜索功能 | | **Groq** | 提供免费层级 | 极速推理 (Llama, Mixtral) | +| **Cerebras** | 提供免费层级 | 极速推理 (Llama, Qwen 等) | diff --git a/pkg/config/config.go b/pkg/config/config.go index 808991d5c..917a4887c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" "reflect" - "sync" + "sync/atomic" "github.com/caarlos0/env/v11" "github.com/go-viper/mapstructure/v2" @@ -56,9 +56,11 @@ type Config struct { Tools ToolsConfig `json:"tools"` Heartbeat HeartbeatConfig `json:"heartbeat"` Devices DevicesConfig `json:"devices"` - mu sync.RWMutex } +// rrCounter is reserved for round-robin model selection compatibility. +var rrCounter atomic.Uint64 + var configFileNames = []string{ "config.json", "config.yaml", @@ -523,9 +525,6 @@ func LoadConfig(path string) (*Config, error) { } func SaveConfig(path string, cfg *Config) error { - cfg.mu.RLock() - defer cfg.mu.RUnlock() - ext := filepath.Ext(path) var configType string switch ext { @@ -587,14 +586,10 @@ func ResolveConfigPath(home string) string { } func (c *Config) WorkspacePath() string { - c.mu.RLock() - defer c.mu.RUnlock() return expandHome(c.Agents.Defaults.Workspace) } func (c *Config) GetAPIKey() string { - c.mu.RLock() - defer c.mu.RUnlock() if c.Providers.OpenRouter.APIKey != "" { return c.Providers.OpenRouter.APIKey } @@ -623,8 +618,6 @@ func (c *Config) GetAPIKey() string { } func (c *Config) GetAPIBase() string { - c.mu.RLock() - defer c.mu.RUnlock() if c.Providers.OpenRouter.APIKey != "" { if c.Providers.OpenRouter.APIBase != "" { return c.Providers.OpenRouter.APIBase @@ -648,8 +641,6 @@ type ModelConfig struct { // GetModelConfig returns the text model configuration with fallbacks. func (c *Config) GetModelConfig() ModelConfig { - c.mu.RLock() - defer c.mu.RUnlock() return ModelConfig{ Primary: c.Agents.Defaults.Model, Fallbacks: c.Agents.Defaults.ModelFallbacks, @@ -658,8 +649,6 @@ func (c *Config) GetModelConfig() ModelConfig { // GetImageModelConfig returns the image model configuration with fallbacks. func (c *Config) GetImageModelConfig() ModelConfig { - c.mu.RLock() - defer c.mu.RUnlock() return ModelConfig{ Primary: c.Agents.Defaults.ImageModel, Fallbacks: c.Agents.Defaults.ImageModelFallbacks,