MCPcopy Create free account
hub / github.com/evilsocket/cake / main

Function main

cake-cli/src/main.rs:96–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94
95#[tokio::main]
96async fn main() -> Result<()> {
97 let cli = Cli::parse();
98
99 // setup logging
100 if std::env::var_os("RUST_LOG").is_none() {
101 // set `RUST_LOG=debug` to see debug logs
102 std::env::set_var("RUST_LOG", "info,tokenizers=error,actix_server=warn");
103 }
104
105 env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
106 .format_module_path(false)
107 .format_target(false)
108 .init();
109
110 match cli.command {
111 Commands::Run { model, prompt, mut args } => {
112 match (model, args.cluster_key.is_some()) {
113 // No model + cluster key → worker mode
114 (None, true) => {
115 args.mode = Mode::Worker;
116 run_as_worker(args).await
117 }
118 // No model, no cluster key → error
119 (None, false) => {
120 anyhow::bail!(
121 "model is required. Usage:\n \
122 cake run <model> [prompt] # local inference\n \
123 cake run <model> --cluster-key K # distributed master\n \
124 cake run --cluster-key K # distributed worker"
125 );
126 }
127 // Model specified → master mode (local or distributed)
128 (Some(m), _) => {
129 args.model = m;
130 if let Some(p) = prompt {
131 args.prompt = p;
132 }
133 args.mode = Mode::Master;
134 run_as_master(args).await
135 }
136 }
137 }
138 Commands::Serve { model, address, mut args } => {
139 args.model = model;
140 args.api = Some(address);
141 args.mode = Mode::Master;
142 run_as_master(args).await
143 }
144 Commands::List => {
145 let models = utils::models::list_models()?;
146 if models.is_empty() {
147 println!("No models found.");
148 println!();
149 println!("Download a model with:");
150 println!(" cake pull <org/model-name>");
151 } else {
152 println!(
153 "{:<50} {:<15} {:<15} SOURCE",

Callers

nothing calls this directly

Calls 11

run_as_workerFunction · 0.85
run_as_masterFunction · 0.85
run_localFunction · 0.85
run_remoteFunction · 0.85
looks_like_hf_repoFunction · 0.85
ensure_model_downloadedFunction · 0.85
find_modelFunction · 0.85
delete_modelFunction · 0.85
split_modelFunction · 0.85
human_bytesFunction · 0.70
list_modelsFunction · 0.50

Tested by

no test coverage detected