Save configuration to file and keyring. Args: api_key: API key (stored in keyring) base_url: LLM API base URL main_model: Primary model cluster_model: Clustering model fallback_model: Fallback model default_out
(
self,
api_key: Optional[str] = None,
base_url: Optional[str] = None,
main_model: Optional[str] = None,
cluster_model: Optional[str] = None,
fallback_model: Optional[str] = None,
default_output: Optional[str] = None,
max_tokens: Optional[int] = None,
max_token_per_module: Optional[int] = None,
max_token_per_leaf_module: Optional[int] = None,
max_depth: Optional[int] = None,
provider: Optional[str] = None,
aws_region: Optional[str] = None,
api_version: Optional[str] = None,
azure_deployment: Optional[str] = None
)
| 121 | self._api_key = self._load_api_key_from_file() |
| 122 | |
| 123 | return True |
| 124 | except (json.JSONDecodeError, FileSystemError) as e: |
| 125 | raise ConfigurationError(f"Failed to load configuration: {e}") |
| 126 | |
| 127 | def save( |
| 128 | self, |
| 129 | api_key: Optional[str] = None, |
| 130 | base_url: Optional[str] = None, |
| 131 | main_model: Optional[str] = None, |
| 132 | cluster_model: Optional[str] = None, |
| 133 | fallback_model: Optional[str] = None, |
| 134 | default_output: Optional[str] = None, |
| 135 | max_tokens: Optional[int] = None, |
| 136 | max_token_per_module: Optional[int] = None, |
| 137 | max_token_per_leaf_module: Optional[int] = None, |
| 138 | max_depth: Optional[int] = None, |
| 139 | provider: Optional[str] = None, |
| 140 | aws_region: Optional[str] = None, |
| 141 | api_version: Optional[str] = None, |
| 142 | azure_deployment: Optional[str] = None, |
| 143 | use_gitignore: Optional[bool] = None, |
| 144 | prompt_caching: Optional[bool] = None, |
| 145 | ): |
| 146 | """ |
| 147 | Save configuration to file and keyring. |
| 148 | |
| 149 | Args: |
| 150 | api_key: API key (stored in keyring) |
| 151 | base_url: LLM API base URL |
| 152 | main_model: Primary model |
| 153 | cluster_model: Clustering model |
| 154 | fallback_model: Fallback model |
| 155 | default_output: Default output directory |
| 156 | max_tokens: Maximum tokens for LLM response |
| 157 | max_token_per_module: Maximum tokens per module for clustering |
| 158 | max_token_per_leaf_module: Maximum tokens per leaf module |
| 159 | max_depth: Maximum depth for hierarchical decomposition |
| 160 | provider: LLM provider type (openai-compatible, anthropic, bedrock, azure-openai) |
| 161 | aws_region: AWS region for Bedrock provider |
| 162 | api_version: Azure OpenAI API version |
| 163 | azure_deployment: Azure OpenAI deployment name |
| 164 | use_gitignore: Apply Git ignore rules during repository analysis |
| 165 | prompt_caching: Add prompt-cache breakpoints to agentic LLM calls |
| 166 | """ |
| 167 | # Ensure config directory exists |
| 168 | try: |
| 169 | ensure_directory(CONFIG_DIR) |
| 170 | except FileSystemError as e: |
| 171 | raise ConfigurationError(f"Cannot create config directory: {e}") |
| 172 | |
| 173 | # Load existing config or create new |
| 174 | if self._config is None: |
| 175 | if CONFIG_FILE.exists(): |
| 176 | self.load() |
| 177 | else: |
| 178 | from codewiki.cli.models.config import AgentInstructions |
| 179 | |
| 180 | self._config = Configuration( |
no test coverage detected