MCPcopy
hub / github.com/HKUDS/DeepTutor / run_init

Function run_init

deeptutor_cli/init_cmd.py:380–506  ·  view source on GitHub ↗
(*, cli_only: bool = False, home: str | Path | None = None)

Source from the content-addressed store, hash-verified

378
379
380def run_init(*, cli_only: bool = False, home: str | Path | None = None) -> None:
381 runtime_home = get_runtime_home(home)
382 runtime_home.mkdir(parents=True, exist_ok=True)
383 import os
384
385 os.environ[DEEPTUTOR_HOME_ENV] = str(runtime_home)
386 _reset_runtime_singletons()
387
388 from deeptutor.runtime.banner import labels_for, print_banner, resolve_language
389 from deeptutor.services.config import get_model_catalog_service, get_runtime_settings_service
390 from deeptutor.services.setup import init_user_directories
391
392 init_user_directories(runtime_home)
393
394 language = resolve_language()
395 strings = labels_for(language)
396 console = Console()
397 # CLI-only: LLM, Embedding, Search, Review = 4 steps.
398 # Full: Ports, LLM, Embedding, Search, Review = 5 steps.
399 total_steps = 4 if cli_only else 5
400
401 try:
402 print_banner(console, language=language, mode_key="init.mode")
403 console.print(f"{strings['init.workspace']}: [bold]{runtime_home}[/bold]")
404 console.print(f"[dim]{strings['init.note_settings_dir']}[/dim]")
405
406 runtime = get_runtime_settings_service()
407 system = runtime.load_system(include_process_overrides=False)
408
409 # --- Step 1 (CLI mode skips ports) ---
410 step_num = 0
411 if not cli_only:
412 step_num += 1
413 wiz.step_header(
414 console,
415 strings["init.step_ports"].format(n=step_num, total=total_steps),
416 )
417 system["backend_port"] = int(
418 typer.prompt(
419 strings["init.backend_port"],
420 default=str(system.get("backend_port") or 8001),
421 )
422 )
423 system["frontend_port"] = int(
424 typer.prompt(
425 strings["init.frontend_port"],
426 default=str(system.get("frontend_port") or 3782),
427 )
428 )
429
430 # --- Step 2: LLM ---
431 catalog_service = get_model_catalog_service()
432 catalog = catalog_service.load()
433 llm_profile, llm_model = _ensure_model_service(
434 catalog, "llm", "llm-profile-default", "llm-model-default"
435 )
436 step_num += 1
437 wiz.step_header(console, strings["init.step_llm"].format(n=step_num, total=total_steps))

Callers 2

mainFunction · 0.90
init_commandFunction · 0.85

Calls 15

get_runtime_homeFunction · 0.90
init_user_directoriesFunction · 0.90
resolve_languageFunction · 0.90
labels_forFunction · 0.90
print_bannerFunction · 0.90
_ensure_model_serviceFunction · 0.85
_llm_stepFunction · 0.85
_embedding_stepFunction · 0.85
_search_stepFunction · 0.85
_ensure_search_serviceFunction · 0.85

Tested by

no test coverage detected