MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / save

Method save

codewiki/cli/config_manager.py:123–246  ·  view source on GitHub ↗

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
    )

Source from the content-addressed store, hash-verified

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(

Callers 2

config_setFunction · 0.95
config_agentFunction · 0.95

Calls 11

loadMethod · 0.95
_save_api_key_to_fileMethod · 0.95
ensure_directoryFunction · 0.90
ConfigurationErrorClass · 0.90
ConfigurationClass · 0.90
AgentInstructionsClass · 0.90
is_caw_providerFunction · 0.90
safe_writeFunction · 0.90
validateMethod · 0.80
warningMethod · 0.80
to_dictMethod · 0.45

Tested by

no test coverage detected