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