use std::{error::Error, process}; mod bot; mod config; mod generator; mod model; mod publish; const CONFIG_PATH: &str = "bot_config.json"; fn main() -> Result<(), Box> { let cfg = match config::Config::from(CONFIG_PATH.to_string()) { Ok(cfg) => cfg, Err(_) => { println!( "Failed reading config at [{}], writing default", CONFIG_PATH ); match config::Config::default().save(CONFIG_PATH.to_string()) { Some(err) => println!("Failed writing file to {}: {}", CONFIG_PATH, err), None => (), } process::exit(1); } }; let gpt_model = model::GPTSampleModel::new( cfg.python_path(), cfg.gpt_code_path(), vec![ "generate_unconditional_samples.py".to_string(), "--model_name".to_string(), cfg.model_name(), "--temperature".to_string(), cfg.temperature(), "--top_k".to_string(), cfg.top_k(), "--nsamples".to_string(), "1".to_string(), ], ); let publisher = publish::FediversePublisher::new(cfg.fediverse_base_url())?; let gen = generator::Generator::new(gpt_model); let mut bot = bot::IzzilisBot::new(gen, publisher); match bot.publish() { Some(err) => Err(err), None => Ok(()), } }