Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
fix/init-local-backends (#746)
Louis Choqueldf6c8f43cf71
diff --git a/pipelex/cli/commands/init/backends.py b/pipelex/cli/commands/init/backends.pyindex e746c632e..fb529eb58 100644--- a/pipelex/cli/commands/init/backends.py+++ b/pipelex/cli/commands/init/backends.py@@ -137,27 +137,49 @@ def customize_backends_config(is_first_time_setup: bool = False, target_config_dexcept Exception as exc:log.debug(f"IDE extension suggestion failed: {exc}")- # Check if pipelex_gateway is selected and handle terms acceptance+ # Check if pipelex_gateway is selected and handle terms acceptance prompt+ gateway_terms_accepted: bool | None = Noneif PipelexBackend.GATEWAY in selected_backends:gateway_accepted = prompt_gateway_acceptance(console)if gateway_accepted:display_gateway_accepted_message(console)- update_service_terms_acceptance(accepted=True, config_dir=config_manager.global_config_dir)+ gateway_terms_accepted = Trueelse:display_gateway_declined_message(console)- update_service_terms_acceptance(accepted=False, config_dir=config_manager.global_config_dir)+ gateway_terms_accepted = False# Remove pipelex_gateway from selected indicesselected_indices = [idx for idx in selected_indices if backend_options[idx][0] != PipelexBackend.GATEWAY]- # Business logic: Update TOML+ # Business logic: Update and save backends.toml first (local operation)update_backends_in_toml(toml_doc, selected_indices, backend_options)save_toml_to_path(toml_doc, backends_toml_path)# UI: Display confirmationdisplay_selected_backends(console, selected_indices, backend_options)+ # Save gateway terms acceptance to global config (separate from backends save)+ if gateway_terms_accepted is not None:+ try:+ global_config_dir = config_manager.global_config_dir+ global_config_dir.mkdir(parents=True, exist_ok=True)+ update_service_terms_acceptance(accepted=gateway_terms_accepted, config_dir=global_config_dir)+ except Exception as terms_exc:+ log.warning(f"Could not save gateway terms acceptance to global config: {terms_exc}")+ if gateway_terms_accepted:+ # Gateway enabled in backends.toml but terms not recorded — runtime will fail.+ # Disable gateway as a safety measure.+ try:+ disable_gateway_backend(backends_toml_path)+ console.print("[yellow]⚠ Could not save gateway terms. Gateway has been disabled to prevent errors.[/yellow]")+ except Exception as disable_exc:+ log.warning(f"Could not disable gateway backend: {disable_exc}")+ console.print(+ "[red]⚠ Could not save gateway terms or disable gateway. Please manually disable pipelex_gateway in backends.toml.[/red]"+ )+ console.print("[dim]Re-run 'pipelex init' to set up gateway again.[/dim]")+except Exception as exc:console.print(f"[yellow]⚠ Warning: Failed to customize backends: {escape(str(exc))}[/yellow]")console.print("[dim]You can manually edit .pipelex/inference/backends.toml later[/dim]")