MCPcopy Index your code
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 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

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