Bỏ qua để đến nội dung

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.

Galaxy CLI tìm file config.json theo thứ tự:

  1. Project-level: ./config.json (trong thư mục hiện tại)
  2. User-level: Global config

~/.galaxy/config.json

Terminal window
# Tạo config trong project hiện tại
touch config.json
Terminal window
# Tạo thư mục và config file
mkdir -p ~/.galaxy
touch ~/.galaxy/config.json
{
"agent": "auto",
"test": false,
"review": false
}
{
"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
}
}

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

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)
}

Cấu hình API keys cho các AI providers:

{
"apiKeys": {
"gemini": "AIza...",
"claude": "sk-ant-...",
"openai": "sk-..."
}
}

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, deterministic
  • 0.4 - 0.7: Balanced (recommended)
  • 0.8 - 1.0: Creative, exploratory

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
}
}
{
"agent": "ollama",
"test": true,
"review": true,
"git": false,
"modelConfig": {
"temperature": 0.5
}
}
{
"agent": "auto",
"test": true,
"review": true,
"git": true,
"apiKeys": {
"gemini": "$GEMINI_API_KEY",
"claude": "$CLAUDE_API_KEY"
},
"modelConfig": {
"temperature": 0.3
}
}
{
"agent": "gemini",
"test": false,
"review": false,
"git": false,
"modelConfig": {
"temperature": 0.8
}
}
{
"agent": "claude",
"test": true,
"review": true,
"git": true,
"tools": {
"fileOperations": true,
"gitOperations": true,
"commandRunner": false // Disable for security
}
}

Bạn có thể sử dụng environment variables trong config:

{
"apiKeys": {
"gemini": "$GEMINI_API_KEY",
"claude": "$CLAUDE_API_KEY"
}
}
Terminal window
# 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"' >> ~/.bashrc
source ~/.bashrc

Galaxy CLI tự động validate config khi khởi động:

Terminal window
galaxy
Configuration loaded: ./config.json
Agent: auto (using Gemini)
API Keys: Gemini ✓, Claude
Test planning: OFF
Code review: OFF

Nếu có lỗi:

Terminal window
Invalid configuration
- apiKeys.gemini: Invalid format
- modelConfig.temperature: Must be between 0 and 1
Terminal window
# Tạo config mẫu
galaxy init
# Tạo với template
galaxy init --template=production
galaxy init --template=development
{
"agent": "auto",
"test": false,
"review": false
}
Terminal window
# macOS/Linux
code config.json
# Windows
code config.json

Sau khi chỉnh sửa, validate JSON syntax:

Copy nội dung và paste vào: https://jsonlint.com

Terminal window
# Check config location
galaxy --config
# Validate config
galaxy --validate-config
Terminal window
# Test API keys
galaxy --test-api-keys
# Output:
# Gemini: ✓ Valid
# Claude: ✗ Invalid or expired
# OpenAI: - Not configured
Terminal window
# Override cho 1 lần chạy
galaxy --agent=claude --test --review