AQIT 0.1.0
Loading...
Searching...
No Matches
session.py
Go to the documentation of this file.
1# Copyright (c) 2025-present Aquin Labs Private Limited. All Rights Reserved.
2# This file is part of the Aquin Engine. Unauthorized copying, modification,
3# distribution, or use of this file, via any medium, is strictly prohibited.
4# Proprietary and confidential. See LICENSE for terms.
5
6"""Session: load / unload / prompt / status."""
7
8from __future__ import annotations
9
10from typing import Any
11
12
13def load_model(model_id: str, *, as_json: bool = False) -> str:
14 """Load a HuggingFace / family model into VRAM (daemon if available)."""
15 from aquin.cli import load_model_local
16
17 return load_model_local(model_id, as_json=as_json)
18
19
20def unload(*, stop_daemon: bool = False) -> None:
21 """Free the resident model from VRAM."""
22 from aquin.cli import cmd_unload
23
24 args: list[str] = []
25 if stop_daemon:
26 args.append("--stop")
27 cmd_unload(args)
28
29
30def active_model() -> str | None:
31 """Return the currently loaded model id, if any."""
32 from aquin.compute.model_loader import get_active_model_id
33
34 mid = get_active_model_id()
35 return mid or None
36
37
38def status(*, as_dict: bool = True) -> dict[str, Any] | None:
39 """Local engine / model status snapshot."""
40 from aquin.status_display import collect_status_snapshot, status_payload
41
42 snap = collect_status_snapshot()
43 if as_dict:
44 return status_payload(snap)
45 from aquin.status_display import render_status
46
47 render_status(snap)
48 return None
49
50
51def prompt(text: str, *extra: str) -> None:
52 """Quick generation against the loaded model (prints like the CLI)."""
53 from aquin.cli import cmd_prompt
54
55 cmd_prompt([text, *extra])
None prompt(str text, *str extra)
Definition session.py:55
str|None active_model()
Definition session.py:34
str load_model(str model_id, *, bool as_json=False)
Definition session.py:17
dict[str, Any]|None status(*, bool as_dict=True)
Definition session.py:42
None unload(*, bool stop_daemon=False)
Definition session.py:24