mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-03-19 03:43:08 +00:00
refactor: make Settings UI the single source of truth for API provider
Remove legacy env-var-based provider/mode detection that caused misleading UI badges (e.g., GLM badge showing when Settings was set to Claude). Key changes: - Remove _is_glm_mode() and _is_ollama_mode() env-var sniffing functions from server/routers/settings.py; derive glm_mode/ollama_mode purely from the api_provider setting - Remove `import os` from settings router (no longer needed) - Update schema comments to reflect settings-based derivation - Remove "(configured via .env)" from badge tooltips in App.tsx - Remove Kimi/GLM/Ollama/Playwright-headless sections from .env.example; add note pointing to Settings UI - Update CLAUDE.md and README.md documentation to reference Settings UI for alternative provider configuration - Update model IDs from claude-opus-4-5-20251101 to claude-opus-4-6 across registry, client, chat sessions, tests, and UI defaults - Add LEGACY_MODEL_MAP with auto-migration in get_all_settings() - Show model ID subtitle in SettingsModal model selector - Add Vertex passthrough test for claude-opus-4-6 (no date suffix) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,6 @@ Settings are stored in the registry database and shared across all projects.
|
||||
"""
|
||||
|
||||
import mimetypes
|
||||
import os
|
||||
import sys
|
||||
|
||||
from fastapi import APIRouter
|
||||
@@ -39,19 +38,6 @@ def _parse_yolo_mode(value: str | None) -> bool:
|
||||
return (value or "false").lower() == "true"
|
||||
|
||||
|
||||
def _is_glm_mode() -> bool:
|
||||
"""Check if GLM API is configured via environment variables."""
|
||||
base_url = os.getenv("ANTHROPIC_BASE_URL", "")
|
||||
# GLM mode is when ANTHROPIC_BASE_URL is set but NOT pointing to Ollama
|
||||
return bool(base_url) and not _is_ollama_mode()
|
||||
|
||||
|
||||
def _is_ollama_mode() -> bool:
|
||||
"""Check if Ollama API is configured via environment variables."""
|
||||
base_url = os.getenv("ANTHROPIC_BASE_URL", "")
|
||||
return "localhost:11434" in base_url or "127.0.0.1:11434" in base_url
|
||||
|
||||
|
||||
@router.get("/providers", response_model=ProvidersResponse)
|
||||
async def get_available_providers():
|
||||
"""Get list of available API providers."""
|
||||
@@ -116,9 +102,8 @@ async def get_settings():
|
||||
|
||||
api_provider = all_settings.get("api_provider", "claude")
|
||||
|
||||
# Compute glm_mode / ollama_mode from api_provider for backward compat
|
||||
glm_mode = api_provider == "glm" or _is_glm_mode()
|
||||
ollama_mode = api_provider == "ollama" or _is_ollama_mode()
|
||||
glm_mode = api_provider == "glm"
|
||||
ollama_mode = api_provider == "ollama"
|
||||
|
||||
return SettingsResponse(
|
||||
yolo_mode=_parse_yolo_mode(all_settings.get("yolo_mode")),
|
||||
@@ -181,8 +166,8 @@ async def update_settings(update: SettingsUpdate):
|
||||
# Return updated settings
|
||||
all_settings = get_all_settings()
|
||||
api_provider = all_settings.get("api_provider", "claude")
|
||||
glm_mode = api_provider == "glm" or _is_glm_mode()
|
||||
ollama_mode = api_provider == "ollama" or _is_ollama_mode()
|
||||
glm_mode = api_provider == "glm"
|
||||
ollama_mode = api_provider == "ollama"
|
||||
|
||||
return SettingsResponse(
|
||||
yolo_mode=_parse_yolo_mode(all_settings.get("yolo_mode")),
|
||||
|
||||
@@ -411,8 +411,8 @@ class SettingsResponse(BaseModel):
|
||||
"""Response schema for global settings."""
|
||||
yolo_mode: bool = False
|
||||
model: str = DEFAULT_MODEL
|
||||
glm_mode: bool = False # True if GLM API is configured via .env
|
||||
ollama_mode: bool = False # True if Ollama API is configured via .env
|
||||
glm_mode: bool = False # True when api_provider is "glm"
|
||||
ollama_mode: bool = False # True when api_provider is "ollama"
|
||||
testing_agent_ratio: int = 1 # Regression testing agents (0-3)
|
||||
playwright_headless: bool = True
|
||||
batch_size: int = 3 # Features per coding agent batch (1-3)
|
||||
|
||||
@@ -157,7 +157,7 @@ class AssistantChatSession:
|
||||
"""
|
||||
Manages a read-only assistant conversation for a project.
|
||||
|
||||
Uses Claude Opus 4.5 with only read-only tools enabled.
|
||||
Uses Claude Opus with only read-only tools enabled.
|
||||
Persists conversation history to SQLite.
|
||||
"""
|
||||
|
||||
@@ -258,11 +258,11 @@ class AssistantChatSession:
|
||||
system_cli = shutil.which("claude")
|
||||
|
||||
# Build environment overrides for API configuration
|
||||
from registry import get_effective_sdk_env
|
||||
from registry import DEFAULT_MODEL, get_effective_sdk_env
|
||||
sdk_env = get_effective_sdk_env()
|
||||
|
||||
# Determine model from SDK env (provider-aware) or fallback to env/default
|
||||
model = sdk_env.get("ANTHROPIC_DEFAULT_OPUS_MODEL") or os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", "claude-opus-4-5-20251101")
|
||||
model = sdk_env.get("ANTHROPIC_DEFAULT_OPUS_MODEL") or os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", DEFAULT_MODEL)
|
||||
|
||||
try:
|
||||
logger.info("Creating ClaudeSDKClient...")
|
||||
|
||||
@@ -154,11 +154,11 @@ class ExpandChatSession:
|
||||
system_prompt = skill_content.replace("$ARGUMENTS", project_path)
|
||||
|
||||
# Build environment overrides for API configuration
|
||||
from registry import get_effective_sdk_env
|
||||
from registry import DEFAULT_MODEL, get_effective_sdk_env
|
||||
sdk_env = get_effective_sdk_env()
|
||||
|
||||
# Determine model from SDK env (provider-aware) or fallback to env/default
|
||||
model = sdk_env.get("ANTHROPIC_DEFAULT_OPUS_MODEL") or os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", "claude-opus-4-5-20251101")
|
||||
model = sdk_env.get("ANTHROPIC_DEFAULT_OPUS_MODEL") or os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", DEFAULT_MODEL)
|
||||
|
||||
# Build MCP servers config for feature creation
|
||||
mcp_servers = {
|
||||
|
||||
@@ -346,7 +346,7 @@ class AgentProcessManager:
|
||||
|
||||
Args:
|
||||
yolo_mode: If True, run in YOLO mode (skip testing agents)
|
||||
model: Model to use (e.g., claude-opus-4-5-20251101)
|
||||
model: Model to use (e.g., claude-opus-4-6)
|
||||
parallel_mode: DEPRECATED - ignored, always uses unified orchestrator
|
||||
max_concurrency: Max concurrent coding agents (1-5, default 1)
|
||||
testing_agent_ratio: Number of regression testing agents (0-3, default 1)
|
||||
|
||||
@@ -140,11 +140,11 @@ class SpecChatSession:
|
||||
system_cli = shutil.which("claude")
|
||||
|
||||
# Build environment overrides for API configuration
|
||||
from registry import get_effective_sdk_env
|
||||
from registry import DEFAULT_MODEL, get_effective_sdk_env
|
||||
sdk_env = get_effective_sdk_env()
|
||||
|
||||
# Determine model from SDK env (provider-aware) or fallback to env/default
|
||||
model = sdk_env.get("ANTHROPIC_DEFAULT_OPUS_MODEL") or os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", "claude-opus-4-5-20251101")
|
||||
model = sdk_env.get("ANTHROPIC_DEFAULT_OPUS_MODEL") or os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", DEFAULT_MODEL)
|
||||
|
||||
try:
|
||||
self.client = ClaudeSDKClient(
|
||||
|
||||
Reference in New Issue
Block a user