Initial commit.
This commit is contained in:
53
src/main.rs
Normal file
53
src/main.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use color_eyre::{
|
||||
Result,
|
||||
eyre::WrapErr,
|
||||
};
|
||||
use human_panic::setup_panic;
|
||||
use tracing::{
|
||||
Level,
|
||||
info,
|
||||
};
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
|
||||
mod chat;
|
||||
mod command;
|
||||
mod qna;
|
||||
mod setup;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
// Some error sprucing.
|
||||
better_panic::install();
|
||||
setup_panic!();
|
||||
|
||||
let subscriber = FmtSubscriber::builder()
|
||||
.with_max_level(Level::TRACE)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::set_global_default(subscriber)
|
||||
.wrap_err("Failed to setup trace logging.")?;
|
||||
|
||||
info!("Starting");
|
||||
|
||||
let settings = setup::init().await.wrap_err("Failed to initialize.")?;
|
||||
let config = settings.config;
|
||||
|
||||
let handle = qna::new(
|
||||
config.get_string("api-key").wrap_err("API missing.")?,
|
||||
config
|
||||
.get_string("base-url")
|
||||
.wrap_err("base-url missing.")?,
|
||||
config
|
||||
.get_string("model")
|
||||
.wrap_err("model string missing.")?,
|
||||
"You are a shady, yet helpful IRC bot. You try to give responses that can
|
||||
be sent in a single IRC response according to the specification."
|
||||
.to_string(),
|
||||
)
|
||||
.wrap_err("Couldn't initialize LLM handle.")?;
|
||||
let mut c = chat::new(&config, &handle).await?;
|
||||
|
||||
c.run().await.unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user