Current section

Files

Jump to
llm_db lib llm_db application.ex
Raw

lib/llm_db/application.ex

defmodule LLMDB.Application do
@moduledoc """
OTP Application for LLMDB.
Automatically loads the pre-built snapshot on application start.
The snapshot is generated by `mix llm_db.build` and packaged
with the release.
"""
use Application
@impl true
def start(_type, _args) do
# Load .env file if it exists
LLMDB.Dotenv.load!()
# Ensure modality atoms exist before loading snapshot
_ = LLMDB.Generated.ValidModalities.list()
if Application.get_env(:llm_db, :skip_packaged_load, false) do
{:ok, self()}
else
case LLMDB.load() do
{:ok, _snapshot} ->
{:ok, self()}
{:error, reason} ->
{:error, reason}
end
end
end
end