AQIT 0.1.0
Loading...
Searching...
No Matches
aquin.cli Namespace Reference

Functions

dict _load_config ()
None _save_config (dict data)
str _get_api_key (str|None explicit=None)
None cmd_status (list[str] args)
None cmd_version (list[str] args)
None cmd_license (list[str] args)
None cmd_update (list[str] args)
tuple[str, str] _detect_desktop_platform ()
None cmd_desktop (list[str] args)
None cmd_list (list[str] args)
None cmd_info (list[str] args)
Path|None _default_sae_load_output (str sae_id)
int|None _layer_from_filename_cli (Path path)
None _print_load_sae_help ()
None _warm_daemon_sae (str model_id, int layer)
None _cmd_load_sae (list[str] args)
str _require_loaded_model_id ()
str _require_locked_model_id ()
None _assert_no_model_override (list[str] raw_args)
dict _build_tool_ctx (str|None model_id=None)
None cmd_trace (list[str] args)
None cmd_feature_logits (list[str] args)
None cmd_feature_neighbors (list[str] args)
None _push_log (str line)
str load_model_local (str model_id, *, bool as_json=False)
None cmd_unload (list[str] args)
None cmd_load (list[str] args)
None cmd_chat (list[str] args)
None cmd_prompt (list[str] args)
dict _connected_state ()
bool _has_loaded_model ()
str|None _session_mode ()
dict[str, str] _active_cli_tool_map ()
dict _inject_session_mode (dict state)
None _guard_llm_only_cmd (str cmd)
None _model_switch_hint (str|None mode)
None _guard_tool_verb (str verb)
Any _coerce_flag_value (str val)
None _normalize_topk_flags (dict[str, Any] tool_args)
dict[str, Any] _parse_tool_flags (list[str] raw)
bool _pop_umap_flag (dict[str, Any] tool_args, list[str]|None raw_args=None)
int|None _coerce_feature_idx (Any value)
list[int] _feature_idxs_from_payload (Any result, dict[str, Any]|None tool_args=None)
int|None _layer_from_payload (Any result, dict[str, Any]|None tool_args=None)
None _run_umap_followup (dict[str, Any] ctx, *, Any result=None, dict[str, Any]|None tool_args=None, str|None ensure_model=None, int|None layer=None, list[int]|None feature_idxs=None)
None _cmd_simulation_catalog (str verb, str tool_name, list[str] extra_args)
None _require_attention_args (str verb, str tool_name, dict[str, Any] tool_args)
None _save_tool_check (str verb, dict[str, Any] result, str|None tool_name)
None cmd_tool (str verb, list[str] raw_args)
bool _try_simulation_phrase (list[str] args)
None cmd_help (list[str] args)
None main ()
None _cli_main ()

Variables

str _CONFIG_PATH = Path.home() / ".aquin" / "config.json"
str _BASE_URL = "https://api.aquin.app"
dict _CLI_TOOL_MAP = cli_verbs_for_mode(None)
frozenset _UMAP_FOLLOWUP_VERBS

Function Documentation

◆ _active_cli_tool_map()

dict[str, str] _active_cli_tool_map ( )
protected

Definition at line 1383 of file cli.py.

References _has_loaded_model(), and _session_mode().

Referenced by _guard_tool_verb(), and cmd_tool().

◆ _assert_no_model_override()

None _assert_no_model_override ( list[str] raw_args)
protected

Definition at line 575 of file cli.py.

Referenced by cmd_feature_logits(), cmd_feature_neighbors(), cmd_tool(), and cmd_trace().

◆ _build_tool_ctx()

dict _build_tool_ctx ( str | None model_id = None)
protected
Local tool context for GPU dispatch + command tracking.

Definition at line 585 of file cli.py.

References _inject_session_mode().

Referenced by _cmd_simulation_catalog(), cmd_feature_logits(), cmd_feature_neighbors(), and cmd_trace().

◆ _cli_main()

None _cli_main ( )
protected

◆ _cmd_load_sae()

None _cmd_load_sae ( list[str] args)
protected
aquin load sae <model-l{n}> | --user <name> | --path <file>

Definition at line 398 of file cli.py.

References _default_sae_load_output(), _get_api_key(), _layer_from_filename_cli(), _print_load_sae_help(), _require_locked_model_id(), and _warm_daemon_sae().

Referenced by cmd_load().

◆ _cmd_simulation_catalog()

None _cmd_simulation_catalog ( str verb,
str tool_name,
list[str] extra_args )
protected
List/load/compare saved simulation runs :  no GPU model required.

Definition at line 1655 of file cli.py.

References _build_tool_ctx(), and _parse_tool_flags().

Referenced by _try_simulation_phrase(), and cmd_list().

◆ _coerce_feature_idx()

int | None _coerce_feature_idx ( Any value)
protected

Definition at line 1530 of file cli.py.

Referenced by _feature_idxs_from_payload(), and _layer_from_payload().

◆ _coerce_flag_value()

Any _coerce_flag_value ( str val)
protected
Parse CLI flag values: JSON arrays/objects, bools, numbers, or raw strings.

Definition at line 1438 of file cli.py.

Referenced by _parse_tool_flags().

◆ _connected_state()

dict _connected_state ( )
protected

Definition at line 1365 of file cli.py.

◆ _default_sae_load_output()

Path | None _default_sae_load_output ( str sae_id)
protected
Default ~/.aquin/sae/... path for aquin load sae <model-l{n}>.

Definition at line 347 of file cli.py.

Referenced by _cmd_load_sae().

◆ _detect_desktop_platform()

tuple[str, str] _detect_desktop_platform ( )
protected
Return (os_label, arch) for desktop install messaging.

Definition at line 220 of file cli.py.

Referenced by cmd_desktop().

◆ _feature_idxs_from_payload()

list[int] _feature_idxs_from_payload ( Any result,
dict[str, Any] | None tool_args = None )
protected
Collect feature indices from a tool payload / args for UMAP highlighting.

Definition at line 1539 of file cli.py.

References _coerce_feature_idx().

Referenced by _run_umap_followup().

◆ _get_api_key()

str _get_api_key ( str | None explicit = None)
protected
Optional cloud token from env / legacy config :  not required for local use.

Definition at line 35 of file cli.py.

Referenced by _cmd_load_sae().

◆ _guard_llm_only_cmd()

None _guard_llm_only_cmd ( str cmd)
protected

Definition at line 1405 of file cli.py.

References _session_mode().

Referenced by cmd_feature_logits(), cmd_feature_neighbors(), and cmd_trace().

◆ _guard_tool_verb()

None _guard_tool_verb ( str verb)
protected

◆ _has_loaded_model()

bool _has_loaded_model ( )
protected

Definition at line 1370 of file cli.py.

Referenced by _active_cli_tool_map(), _guard_tool_verb(), and _session_mode().

◆ _inject_session_mode()

dict _inject_session_mode ( dict state)
protected

Definition at line 1396 of file cli.py.

References _session_mode().

Referenced by _build_tool_ctx().

◆ _layer_from_filename_cli()

int | None _layer_from_filename_cli ( Path path)
protected

Definition at line 364 of file cli.py.

Referenced by _cmd_load_sae().

◆ _layer_from_payload()

int | None _layer_from_payload ( Any result,
dict[str, Any] | None tool_args = None )
protected

Definition at line 1588 of file cli.py.

References _coerce_feature_idx().

Referenced by _run_umap_followup().

◆ _load_config()

dict _load_config ( )
protected

Definition at line 22 of file cli.py.

◆ _model_switch_hint()

None _model_switch_hint ( str | None mode)
protected

Definition at line 1413 of file cli.py.

Referenced by _guard_tool_verb().

◆ _normalize_topk_flags()

None _normalize_topk_flags ( dict[str, Any] tool_args)
protected

Definition at line 1465 of file cli.py.

Referenced by _parse_tool_flags().

◆ _parse_tool_flags()

dict[str, Any] _parse_tool_flags ( list[str] raw)
protected
Parse --key value flags into an args dict.

Definition at line 1472 of file cli.py.

References _coerce_flag_value(), and _normalize_topk_flags().

Referenced by _cmd_simulation_catalog(), cmd_tool(), and cmd_trace().

◆ _pop_umap_flag()

bool _pop_umap_flag ( dict[str, Any] tool_args,
list[str] | None raw_args = None )
protected

Definition at line 1523 of file cli.py.

Referenced by cmd_tool(), and cmd_trace().

◆ _print_load_sae_help()

None _print_load_sae_help ( )
protected

Definition at line 374 of file cli.py.

Referenced by _cmd_load_sae().

◆ _push_log()

None _push_log ( str line)
protected
Legacy no-op :  web session sync removed.

Definition at line 950 of file cli.py.

Referenced by load_model_local().

◆ _require_attention_args()

None _require_attention_args ( str verb,
str tool_name,
dict[str, Any] tool_args )
protected
`aquin check attention` must include --prompt.

Definition at line 1676 of file cli.py.

Referenced by cmd_tool().

◆ _require_loaded_model_id()

str _require_loaded_model_id ( )
protected
Return the loaded model id, or exit.

Definition at line 555 of file cli.py.

Referenced by _require_locked_model_id().

◆ _require_locked_model_id()

str _require_locked_model_id ( )
protected
Alias :  session lock removed; uses loaded model.

Definition at line 570 of file cli.py.

References _require_loaded_model_id().

Referenced by _cmd_load_sae(), cmd_feature_logits(), cmd_feature_neighbors(), and cmd_trace().

◆ _run_umap_followup()

None _run_umap_followup ( dict[str, Any] ctx,
* ,
Any result = None,
dict[str, Any] | None tool_args = None,
str | None ensure_model = None,
int | None layer = None,
list[int] | None feature_idxs = None )
protected
After a feature-producing command, load UMAP and sync the explorer card.

Definition at line 1612 of file cli.py.

References _feature_idxs_from_payload(), and _layer_from_payload().

Referenced by cmd_feature_logits(), cmd_feature_neighbors(), cmd_tool(), and cmd_trace().

◆ _save_config()

None _save_config ( dict data)
protected

Definition at line 29 of file cli.py.

◆ _save_tool_check()

None _save_tool_check ( str verb,
dict[str, Any] result,
str | None tool_name )
protected
Write JSON + PNG for verbs that support --check.

Definition at line 1690 of file cli.py.

Referenced by cmd_tool().

◆ _session_mode()

str | None _session_mode ( )
protected
Return session mode from the loaded model.

Definition at line 1375 of file cli.py.

References _has_loaded_model().

Referenced by _active_cli_tool_map(), _guard_llm_only_cmd(), _guard_tool_verb(), _inject_session_mode(), and cmd_help().

◆ _try_simulation_phrase()

bool _try_simulation_phrase ( list[str] args)
protected
Dispatch aquin list simulation | compare simulation; redirect load simulation.

Definition at line 1834 of file cli.py.

References _cmd_simulation_catalog(), _guard_tool_verb(), and cmd_list().

Referenced by _cli_main().

◆ _warm_daemon_sae()

None _warm_daemon_sae ( str model_id,
int layer )
protected
Best-effort: cache the SAE in the persistent daemon so tools reuse it.

Definition at line 387 of file cli.py.

Referenced by _cmd_load_sae().

◆ cmd_chat()

None cmd_chat ( list[str] args)
aquin chat :  Ink (via npm), Textual detect, or Rich fallback.

Definition at line 1192 of file cli.py.

Referenced by _cli_main().

◆ cmd_desktop()

None cmd_desktop ( list[str] args)
aquin desktop install  :  install the Aquin desktop app (stub until releases ship).

Definition at line 244 of file cli.py.

References _detect_desktop_platform().

Referenced by _cli_main().

◆ cmd_feature_logits()

None cmd_feature_logits ( list[str] args)
aquin feature logit --feature <idx> [--layer <n>] [--topk <n>] [--check] [--umap]

Definition at line 772 of file cli.py.

References _assert_no_model_override(), _build_tool_ctx(), _guard_llm_only_cmd(), _require_locked_model_id(), and _run_umap_followup().

◆ cmd_feature_neighbors()

None cmd_feature_neighbors ( list[str] args)
aquin feature neighbor --feature <idx> [--layer <n>] [--topk <n>] [--check] [--umap]

Definition at line 862 of file cli.py.

References _assert_no_model_override(), _build_tool_ctx(), _guard_llm_only_cmd(), _require_locked_model_id(), and _run_umap_followup().

◆ cmd_help()

None cmd_help ( list[str] args)

Definition at line 1852 of file cli.py.

References _session_mode().

Referenced by _cli_main().

◆ cmd_info()

None cmd_info ( list[str] args)
aquin info sae <model-l{layer}>

Definition at line 307 of file cli.py.

◆ cmd_license()

None cmd_license ( list[str] args)
Show the AQIT Apache 2.0 license

Definition at line 96 of file cli.py.

Referenced by _cli_main().

◆ cmd_list()

None cmd_list ( list[str] args)
aquin list simulation

Definition at line 282 of file cli.py.

References _cmd_simulation_catalog().

Referenced by _try_simulation_phrase().

◆ cmd_load()

None cmd_load ( list[str] args)
aquin load model <model-id> | sae <model-l{n}>

Definition at line 1140 of file cli.py.

References _cmd_load_sae(), and load_model_local().

Referenced by _cli_main().

◆ cmd_prompt()

None cmd_prompt ( list[str] args)
aquin prompt <text> :  quick try-out generation against the loaded model.

Definition at line 1218 of file cli.py.

Referenced by _cli_main().

◆ cmd_status()

None cmd_status ( list[str] args)
aquin status :  loaded model and local engine state

Definition at line 41 of file cli.py.

Referenced by _cli_main().

◆ cmd_tool()

None cmd_tool ( str verb,
list[str] raw_args )
Generic handler for raw CLI tool verbs :  thin argv layer over ``aquin.sdk``.

Definition at line 1753 of file cli.py.

References _active_cli_tool_map(), _assert_no_model_override(), _guard_tool_verb(), _parse_tool_flags(), _pop_umap_flag(), _require_attention_args(), _run_umap_followup(), and _save_tool_check().

◆ cmd_trace()

None cmd_trace ( list[str] args)
aquin trace --prompt <text> --layer <n> [--check] [--umap]

Definition at line 616 of file cli.py.

References _assert_no_model_override(), _build_tool_ctx(), _guard_llm_only_cmd(), _parse_tool_flags(), _pop_umap_flag(), _require_locked_model_id(), and _run_umap_followup().

◆ cmd_unload()

None cmd_unload ( list[str] args)
aquin unload [--stop] [--json]  :  free the resident model's VRAM.

Definition at line 1070 of file cli.py.

Referenced by _cli_main().

◆ cmd_update()

None cmd_update ( list[str] args)
aquin update  :  upgrade aquin to the latest version from PyPI

Definition at line 153 of file cli.py.

Referenced by _cli_main().

◆ cmd_version()

None cmd_version ( list[str] args)
aquin version  :  show the installed CLI version

Definition at line 78 of file cli.py.

Referenced by _cli_main().

◆ load_model_local()

str load_model_local ( str model_id,
* ,
bool as_json = False )
Load a model into VRAM. Returns the resolved model id.

Definition at line 955 of file cli.py.

References _push_log().

Referenced by cmd_load().

◆ main()

None main ( )

Definition at line 1910 of file cli.py.

References _cli_main().

Variable Documentation

◆ _BASE_URL

str aquin.cli._BASE_URL = "https://api.aquin.app"
protected

Definition at line 19 of file cli.py.

◆ _CLI_TOOL_MAP

dict aquin.cli._CLI_TOOL_MAP = cli_verbs_for_mode(None)
protected

Definition at line 1362 of file cli.py.

◆ _CONFIG_PATH

str aquin.cli._CONFIG_PATH = Path.home() / ".aquin" / "config.json"
protected

Definition at line 18 of file cli.py.

◆ _UMAP_FOLLOWUP_VERBS

frozenset aquin.cli._UMAP_FOLLOWUP_VERBS
protected
Initial value:
= frozenset({
"trace",
"feature locate",
"feature logit",
"feature neighbor",
"steer",
"multi-steer",
"benchmark",
"sae-stats",
"features",
"contrastive",
"interp",
"browser",
"graph",
"circuit",
"steer",
"absorption",
"polysemy",
"faithfulness",
"decomp",
})

Definition at line 1500 of file cli.py.