MCPcopy
hub / github.com/HKUDS/DeepCode / get_default_models

Function get_default_models

utils/llm_utils.py:214–275  ·  view source on GitHub ↗

Get default models from configuration file. Args: config_path: Path to the configuration file Returns: dict: Dictionary with 'anthropic', 'openai', 'google' default models, plus 'google_planning' and 'google_implementation' for phase-specific models

(config_path: str = "mcp_agent.config.yaml")

Source from the content-addressed store, hash-verified

212
213
214def get_default_models(config_path: str = "mcp_agent.config.yaml"):
215 """
216 Get default models from configuration file.
217
218 Args:
219 config_path: Path to the configuration file
220
221 Returns:
222 dict: Dictionary with 'anthropic', 'openai', 'google' default models,
223 plus 'google_planning' and 'google_implementation' for phase-specific models
224 """
225 try:
226 if os.path.exists(config_path):
227 with open(config_path, "r", encoding="utf-8") as f:
228 config = yaml.safe_load(f)
229
230 # Handle null values in config sections
231 anthropic_config = config.get("anthropic") or {}
232 openai_config = config.get("openai") or {}
233 google_config = config.get("google") or {}
234
235 anthropic_model = anthropic_config.get(
236 "default_model", "claude-sonnet-4-20250514"
237 )
238 openai_model = openai_config.get("default_model", "o3-mini")
239 google_model = google_config.get("default_model", "gemini-2.0-flash")
240
241 # Phase-specific models (fall back to default if not specified)
242 # Google
243 google_planning = google_config.get("planning_model", google_model)
244 google_implementation = google_config.get(
245 "implementation_model", google_model
246 )
247 # Anthropic
248 anthropic_planning = anthropic_config.get("planning_model", anthropic_model)
249 anthropic_implementation = anthropic_config.get(
250 "implementation_model", anthropic_model
251 )
252 # OpenAI
253 openai_planning = openai_config.get("planning_model", openai_model)
254 openai_implementation = openai_config.get(
255 "implementation_model", openai_model
256 )
257
258 return {
259 "anthropic": anthropic_model,
260 "openai": openai_model,
261 "google": google_model,
262 "google_planning": google_planning,
263 "google_implementation": google_implementation,
264 "anthropic_planning": anthropic_planning,
265 "anthropic_implementation": anthropic_implementation,
266 "openai_planning": openai_planning,
267 "openai_implementation": openai_implementation,
268 }
269 else:
270 print(f"Config file {config_path} not found, using default models")
271 return _get_fallback_models()

Callers 3

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls 2

_get_fallback_modelsFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected