Cấu hình
Galaxy CLI sử dụng file config.json để quản lý cấu hình. File này cho phép bạn tùy chỉnh hành vi của Galaxy theo nhu cầu.
Vị trí file cấu hình
Phần tiêu đề “Vị trí file cấu hình”Galaxy CLI tìm file config.json theo thứ tự:
- Project-level:
./config.json(trong thư mục hiện tại) - User-level: Global config
~/.galaxy/config.json
%USERPROFILE%\.galaxy\config.json
Hoặc: C:\Users\YourUsername\.galaxy\config.json
Tạo file cấu hình
Phần tiêu đề “Tạo file cấu hình”Project-level (Khuyến nghị)
Phần tiêu đề “Project-level (Khuyến nghị)”# Tạo config trong project hiện tạitouch config.json# Tạo config trong project hiện tạiNew-Item -Path . -Name "config.json" -ItemType "file"REM Tạo config trong project hiện tạitype nul > config.jsonUser-level (Global)
Phần tiêu đề “User-level (Global)”# Tạo thư mục và config filemkdir -p ~/.galaxytouch ~/.galaxy/config.json# Tạo thư mục và config fileNew-Item -Path "$env:USERPROFILE\.galaxy" -ItemType Directory -ForceNew-Item -Path "$env:USERPROFILE\.galaxy\config.json" -ItemType "file"REM Tạo thư mục và config filemkdir %USERPROFILE%\.galaxytype nul > %USERPROFILE%\.galaxy\config.jsonCấu trúc file config.json
Phần tiêu đề “Cấu trúc file config.json”Minimal Configuration
Phần tiêu đề “Minimal Configuration”{ "agent": "auto", "test": false, "review": false}Full Configuration
Phần tiêu đề “Full Configuration”{ "agent": "auto", "test": false, "review": false, "git": false, "apiKeys": { "gemini": "your_gemini_api_key", "claude": "your_claude_api_key", "openai": "your_openai_api_key" }, "modelConfig": { "temperature": 0.7, "maxTokens": 8192, "topP": 0.95 }, "tools": { "fileOperations": true, "gitOperations": false, "commandRunner": true, "documentParser": true }}Các tùy chọn cấu hình
Phần tiêu đề “Các tùy chọn cấu hình”Agent Configuration
Phần tiêu đề “Agent Configuration”Chọn AI agent cho Galaxy:
{ "agent": "auto" // "auto" | "gemini" | "claude" | "gpt4" | "ollama"}Options:
"auto"(default) - Galaxy tự động chọn agent phù hợp"gemini"- Sử dụng Google Gemini"claude"- Sử dụng Anthropic Claude"gpt4"- Sử dụng OpenAI GPT-4"ollama"- Sử dụng local Ollama models
Feature Flags
Phần tiêu đề “Feature Flags”Enable/disable các tính năng:
{ "test": false, // Auto-generate tests "review": false, // Code review before completion "git": false // Git operations (commit, push)}API Keys
Phần tiêu đề “API Keys”Cấu hình API keys cho các AI providers:
{ "apiKeys": { "gemini": "AIza...", "claude": "sk-ant-...", "openai": "sk-..." }}Model Parameters
Phần tiêu đề “Model Parameters”Tùy chỉnh behavior của AI models:
{ "modelConfig": { "temperature": 0.7, // Creativity (0-1) "maxTokens": 8192, // Max response length "topP": 0.95 // Nucleus sampling }}Temperature Guide:
0.0 - 0.3: Conservative, deterministic0.4 - 0.7: Balanced (recommended)0.8 - 1.0: Creative, exploratory
Tools Configuration
Phần tiêu đề “Tools Configuration”Enable/disable specific tools:
{ "tools": { "fileOperations": true, // file_read, file_write, etc. "gitOperations": false, // git_commit, git_push, etc. "commandRunner": true, // Run shell commands "documentParser": true, // Parse PDF, DOCX, XLSX "testRunner": false // Run tests }}Ví dụ cấu hình theo use case
Phần tiêu đề “Ví dụ cấu hình theo use case”Development (Local)
Phần tiêu đề “Development (Local)”{ "agent": "ollama", "test": true, "review": true, "git": false, "modelConfig": { "temperature": 0.5 }}Production (Cloud)
Phần tiêu đề “Production (Cloud)”{ "agent": "auto", "test": true, "review": true, "git": true, "apiKeys": { "gemini": "$GEMINI_API_KEY", "claude": "$CLAUDE_API_KEY" }, "modelConfig": { "temperature": 0.3 }}Quick Prototyping
Phần tiêu đề “Quick Prototyping”{ "agent": "gemini", "test": false, "review": false, "git": false, "modelConfig": { "temperature": 0.8 }}Team Project
Phần tiêu đề “Team Project”{ "agent": "claude", "test": true, "review": true, "git": true, "tools": { "fileOperations": true, "gitOperations": true, "commandRunner": false // Disable for security }}Environment Variables
Phần tiêu đề “Environment Variables”Bạn có thể sử dụng environment variables trong config:
{ "apiKeys": { "gemini": "$GEMINI_API_KEY", "claude": "$CLAUDE_API_KEY" }}Set Environment Variables
Phần tiêu đề “Set Environment Variables”# Temporary (session only)export GEMINI_API_KEY="your_key_here"export CLAUDE_API_KEY="your_key_here"
# Permanent (add to ~/.bashrc or ~/.zshrc)echo 'export GEMINI_API_KEY="your_key_here"' >> ~/.bashrcsource ~/.bashrc# Temporary (session only)$env:GEMINI_API_KEY="your_key_here"$env:CLAUDE_API_KEY="your_key_here"
# Permanent (user level)[System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'your_key_here', 'User')[System.Environment]::SetEnvironmentVariable('CLAUDE_API_KEY', 'your_key_here', 'User')REM Temporary (session only)set GEMINI_API_KEY=your_key_hereset CLAUDE_API_KEY=your_key_here
REM Permanent (user level)setx GEMINI_API_KEY "your_key_here"setx CLAUDE_API_KEY "your_key_here"Xác thực cấu hình
Phần tiêu đề “Xác thực cấu hình”Galaxy CLI tự động validate config khi khởi động:
galaxy
✓ Configuration loaded: ./config.json✓ Agent: auto (using Gemini)✓ API Keys: Gemini ✓, Claude ✗✓ Test planning: OFF✓ Code review: OFFNếu có lỗi:
✗ Invalid configuration - apiKeys.gemini: Invalid format - modelConfig.temperature: Must be between 0 and 1Template configs
Phần tiêu đề “Template configs”Generate default config
Phần tiêu đề “Generate default config”# Tạo config mẫugalaxy init
# Tạo với templategalaxy init --template=productiongalaxy init --template=developmentTemplates có sẵn
Phần tiêu đề “Templates có sẵn”{ "agent": "auto", "test": false, "review": false}{ "agent": "claude", "test": true, "review": true, "git": true, "modelConfig": { "temperature": 0.3 }}{ "agent": "ollama", "test": true, "review": true, "git": false, "modelConfig": { "temperature": 0.7 }}Best Practices
Phần tiêu đề “Best Practices”Chỉnh sửa config file
Phần tiêu đề “Chỉnh sửa config file”Sử dụng Text Editor
Phần tiêu đề “Sử dụng Text Editor”# macOS/Linuxcode config.json
# Windowscode config.jsonnotepad config.jsonnano config.jsonvim config.jsonValidate JSON Syntax
Phần tiêu đề “Validate JSON Syntax”Sau khi chỉnh sửa, validate JSON syntax:
Copy nội dung và paste vào: https://jsonlint.com
# Using Node.jsnode -e "JSON.parse(require('fs').readFileSync('config.json', 'utf8'))"
# Using Pythonpython -m json.tool config.jsonVS Code tự động validate JSON và hiển thị errors
Troubleshooting
Phần tiêu đề “Troubleshooting”Config không được load
Phần tiêu đề “Config không được load”# Check config locationgalaxy --config
# Validate configgalaxy --validate-configAPI key không hoạt động
Phần tiêu đề “API key không hoạt động”# Test API keysgalaxy --test-api-keys
# Output:# Gemini: ✓ Valid# Claude: ✗ Invalid or expired# OpenAI: - Not configuredOverride config temporarily
Phần tiêu đề “Override config temporarily”# Override cho 1 lần chạygalaxy --agent=claude --test --reviewĐường dẫn file trên Windows
Phần tiêu đề “Đường dẫn file trên Windows”Các bước tiếp theo
Phần tiêu đề “Các bước tiếp theo”- Command Options - Command-line options
- Commands - Internal commands
- AI Models - Tìm hiểu về AI agents