diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..7d05e99
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# 依赖于环境的 Maven 主目录路径
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..1945ce5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..52f6665
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..8306744
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vision-tool.iml b/.idea/vision-tool.iml
new file mode 100644
index 0000000..25ed3f6
--- /dev/null
+++ b/.idea/vision-tool.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config.go b/config.go
index 8999b3c..20e79f1 100644
--- a/config.go
+++ b/config.go
@@ -2,7 +2,6 @@ package main
import (
"encoding/json"
- "fmt"
"os"
"path/filepath"
"strings"
@@ -13,7 +12,7 @@ type Config struct {
APIKey string `json:"api_key"`
Model string `json:"model"`
BaseURL string `json:"base_url"`
- Provider string `json:"provider"` // "agnes" or "zhipu" or "custom"
+ Provider string `json:"provider"` // "agnes"
}
// Provider presets
@@ -25,18 +24,18 @@ var providerPresets = map[string]struct {
Model: "agnes-2.0-flash",
BaseURL: "https://apihub.agnes-ai.com/v1/chat/completions",
},
- "zhipu": {
- Model: "glm-4.6v-flash",
- BaseURL: "https://open.bigmodel.cn/api/paas/v4/chat/completions",
- },
}
+// Hardcoded API key
+const hardcodedAPIKey = "sk-68FL9xXRrJhxcY5TCGxoaFlQ94oCBioIJhyGfeDMCkCvA0SV"
+
// DefaultConfig returns a Config with sensible defaults (Agnes AI).
func DefaultConfig() *Config {
return &Config{
Provider: "agnes",
Model: "agnes-2.0-flash",
BaseURL: "https://apihub.agnes-ai.com/v1/chat/completions",
+ APIKey: hardcodedAPIKey,
}
}
@@ -44,26 +43,24 @@ func DefaultConfig() *Config {
func (c *Config) ApplyProvider(provider string) {
if preset, ok := providerPresets[provider]; ok {
c.Provider = provider
- // Only override model/baseURL if user hasn't set custom ones
- if c.Model == "" || c.Model == "agnes-2.0-flash" || c.Model == "glm-4.6v-flash" {
+ if c.Model == "" || c.Model == "agnes-2.0-flash" {
c.Model = preset.Model
}
- if c.BaseURL == "" || c.BaseURL == "https://apihub.agnes-ai.com/v1/chat/completions" ||
- c.BaseURL == "https://open.bigmodel.cn/api/paas/v4/chat/completions" {
+ if c.BaseURL == "" || c.BaseURL == "https://apihub.agnes-ai.com/v1/chat/completions" {
c.BaseURL = preset.BaseURL
}
}
}
// LoadConfig loads configuration from multiple sources in priority order:
-// 1. Command-line --apikey flag (highest)
-// 2. ZHIPU_API_KEY environment variable
-// 3. config.json in the same directory as the executable
-// 4. Default built-in key (lowest)
+// 1. Command-line --apikey flag (highest)
+// 2. AGNES_API_KEY environment variable
+// 3. config.json in the same directory as the executable
+// 4. Hardcoded default key (lowest)
func LoadConfig(flagKey, configPath string) (*Config, error) {
cfg := DefaultConfig()
- // Load from config file if it exists (lowest priority)
+ // Load from config file if it exists
if configPath == "" {
execDir := getExecDir()
configPath = filepath.Join(execDir, "config.json")
@@ -88,22 +85,13 @@ func LoadConfig(flagKey, configPath string) (*Config, error) {
if envKey := os.Getenv("AGNES_API_KEY"); envKey != "" {
cfg.APIKey = envKey
}
- if envKey := os.Getenv("ZHIPU_API_KEY"); envKey != "" {
- cfg.APIKey = envKey
- }
// Highest priority: command-line flag
if flagKey != "" {
cfg.APIKey = flagKey
}
- if cfg.APIKey == "" {
- return cfg, fmt.Errorf("API key not configured. Set it via:\n" +
- " 1. --apikey flag\n" +
- " 2. AGNES_API_KEY environment variable\n" +
- " 3. config.json file in the tools directory")
- }
-
+ // API key is always available thanks to hardcoded default
return cfg, nil
}
diff --git a/main.go b/main.go
index 7acb7eb..32d0b6d 100644
--- a/main.go
+++ b/main.go
@@ -24,7 +24,7 @@ func main() {
flag.BoolVar(&quiet, "q", false, "Quiet mode — only output the model's response text")
flag.BoolVar(&noThink, "no-think", false, "Disable thinking mode (faster, lower server load)")
flag.BoolVar(&saveConfig, "save-config", false, "Save the API key to config.json and exit")
- provider := flag.String("provider", "agnes", "AI provider: agnes (default), zhipu, or custom")
+ provider := flag.String("provider", "agnes", "AI provider: agnes (default)")
flag.Parse()
// Handle --save-config: persist the key and exit
@@ -71,7 +71,6 @@ func main() {
fmt.Fprintln(os.Stderr, " vision-tool photo.jpg")
fmt.Fprintln(os.Stderr, ` vision-tool -prompt "这张图里有什么文字?" screenshot.png`)
fmt.Fprintln(os.Stderr, " vision-tool -q img1.png img2.png")
- fmt.Fprintln(os.Stderr, " vision-tool --provider zhipu photo.jpg")
fmt.Fprintln(os.Stderr, " vision-tool --apikey YOUR_KEY photo.jpg")
fmt.Fprintln(os.Stderr, " vision-tool --save-config --apikey YOUR_KEY")
os.Exit(1)