AQIT 0.1.0
Loading...
Searching...
No Matches
aquin.engine.model_daemon Namespace Reference

Functions

int _port ()
str _base ()
str _url (str path)
tuple[int|None, Any] _get (str path, float timeout=1.5)
tuple[int|None, Any] _post (str path, dict|None body, float timeout=DEFAULT_TIMEOUT)
dict|None health (float timeout=1.5)
dict|None health_fast ()
bool is_running ()
str|None loaded_model ()
bool _port_occupied ()
None _write_state (int pid)
None _clear_state ()
bool _spawn ()
bool ensure_running (float wait_seconds=40.0)
dict|None switch_model (str model_id, float timeout=DEFAULT_TIMEOUT, *, Any on_tick=None)
dict|None warm_sae (str model_id, int layer, float timeout=600)
dict|None dispatch (str name, dict args, dict ctx, float timeout=DEFAULT_TIMEOUT)
bool unload ()
dict|None prompt (str text, *, str|None model_id=None, int max_new_tokens=200, float temperature=0.7, float timeout=DEFAULT_TIMEOUT)
bool stop ()

Variables

 _HOST = DEFAULT_ENGINE_HOST
str _LOG_PATH = Path.home() / ".aquin" / "daemon.log"
int DEFAULT_TIMEOUT = 1800
float FAST_TIMEOUT = 0.2

Function Documentation

◆ _base()

str _base ( )
protected

Definition at line 48 of file model_daemon.py.

◆ _clear_state()

None _clear_state ( )
protected

Definition at line 124 of file model_daemon.py.

Referenced by stop().

◆ _get()

tuple[int | None, Any] _get ( str path,
float timeout = 1.5 )
protected

Definition at line 56 of file model_daemon.py.

References _url().

Referenced by _port_occupied(), and health().

◆ _port()

int _port ( )
protected

Definition at line 44 of file model_daemon.py.

Referenced by _spawn(), and _write_state().

◆ _port_occupied()

bool _port_occupied ( )
protected
Something is listening on the port (may be a non-daemon chat server).

Definition at line 105 of file model_daemon.py.

References _get().

Referenced by ensure_running().

◆ _post()

tuple[int | None, Any] _post ( str path,
dict | None body,
float timeout = DEFAULT_TIMEOUT )
protected

Definition at line 65 of file model_daemon.py.

References _url().

Referenced by dispatch(), prompt(), stop(), switch_model(), unload(), and warm_sae().

◆ _spawn()

bool _spawn ( )
protected
Spawn the daemon as a detached background process. Returns spawn success.

Definition at line 131 of file model_daemon.py.

References _port(), and _write_state().

Referenced by ensure_running().

◆ _url()

str _url ( str path)
protected

Definition at line 52 of file model_daemon.py.

Referenced by _get(), and _post().

◆ _write_state()

None _write_state ( int pid)
protected

Definition at line 111 of file model_daemon.py.

References _port().

Referenced by _spawn().

◆ dispatch()

dict | None dispatch ( str name,
dict args,
dict ctx,
float timeout = DEFAULT_TIMEOUT )
Run a tool in the daemon. Returns {"ok": bool, "result"|"error": ...} or None.

Definition at line 221 of file model_daemon.py.

References _post().

◆ ensure_running()

bool ensure_running ( float wait_seconds = 40.0)
Make sure the daemon HTTP server is up. Returns True if it is (or becomes)
reachable. Does NOT load a model; use switch_model for that.

Definition at line 164 of file model_daemon.py.

References _port_occupied(), _spawn(), and is_running().

◆ health()

dict | None health ( float timeout = 1.5)
Return the daemon health payload, or None if no daemon is answering.

Definition at line 83 of file model_daemon.py.

References _get().

Referenced by health_fast(), is_running(), loaded_model(), and switch_model().

◆ health_fast()

dict | None health_fast ( )
Quick probe for status screens :  fails fast when daemon is down.

Definition at line 91 of file model_daemon.py.

References health().

◆ is_running()

bool is_running ( )

Definition at line 96 of file model_daemon.py.

References health().

Referenced by ensure_running().

◆ loaded_model()

str | None loaded_model ( )

Definition at line 100 of file model_daemon.py.

References health().

◆ prompt()

dict | None prompt ( str text,
* ,
str | None model_id = None,
int max_new_tokens = 200,
float temperature = 0.7,
float timeout = DEFAULT_TIMEOUT )
Generate a completion from the daemon's resident model.

Definition at line 235 of file model_daemon.py.

References _post().

◆ stop()

bool stop ( )
Ask the daemon to shut down and clear local state.

Definition at line 257 of file model_daemon.py.

References _clear_state(), and _post().

◆ switch_model()

dict | None switch_model ( str model_id,
float timeout = DEFAULT_TIMEOUT,
* ,
Any on_tick = None )
Load model_id in the daemon, evicting any previously resident model.

Definition at line 184 of file model_daemon.py.

References _post(), and health().

◆ unload()

bool unload ( )
Free the daemon's VRAM (keeps the daemon process alive).

Definition at line 229 of file model_daemon.py.

References _post().

◆ warm_sae()

dict | None warm_sae ( str model_id,
int layer,
float timeout = 600 )

Definition at line 214 of file model_daemon.py.

References _post().

Variable Documentation

◆ _HOST

aquin.engine.model_daemon._HOST = DEFAULT_ENGINE_HOST
protected

Definition at line 36 of file model_daemon.py.

◆ _LOG_PATH

str aquin.engine.model_daemon._LOG_PATH = Path.home() / ".aquin" / "daemon.log"
protected

Definition at line 37 of file model_daemon.py.

◆ DEFAULT_TIMEOUT

int aquin.engine.model_daemon.DEFAULT_TIMEOUT = 1800

Definition at line 40 of file model_daemon.py.

◆ FAST_TIMEOUT

float aquin.engine.model_daemon.FAST_TIMEOUT = 0.2

Definition at line 41 of file model_daemon.py.