// Generated by encoderfile ❤️ DO NOT MODIFY

use anyhow::Result;
use clap::Parser;
use encoderfile_core::{
    factory,
    cli::Cli,
    runtime::{
        get_model,
        get_model_config,
        get_tokenizer,
        get_model_type,
        get_transform,
    },
    AppState,
};

factory! {
    "{{ model_weights_path }}",
    "{{ tokenizer_path }}",
    "{{ model_config_path }}",
    "{{ model_type }}",
    "{{ model_name }}",
    {% if transform %}Some(r###"
{{ transform }}
    "###){% else %}None{% endif %},
}

#[tokio::main]
async fn main() -> Result<()> {
    let cli = Cli::parse();

    let session = get_model(&assets::MODEL_WEIGHTS);
    let config = get_model_config(assets::MODEL_CONFIG_JSON);
    let tokenizer = get_tokenizer(assets::TOKENIZER_JSON, &config);
    let model_type = get_model_type(assets::MODEL_TYPE_STR);
    let model_id = assets::MODEL_ID.to_string();
    let transform_factory = || get_transform(assets::TRANSFORM);


    let state = AppState {
        session,
        config,
        tokenizer,
        model_type,
        model_id,
        transform_factory,
    };

    cli.command.execute(state).await?;

    Ok(())
}
