Breaking out some portions for integration testing.
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
use color_eyre::Result;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Root {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl Root {
|
||||
pub fn new(path: impl AsRef<Path>) -> Self {
|
||||
Root {
|
||||
path: path.as_ref().to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_command(_cmd_string: impl AsRef<str>) -> Result<()> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
12
src/lib.rs
Normal file
12
src/lib.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
// Robotnik libraries
|
||||
|
||||
pub mod chat;
|
||||
pub mod event;
|
||||
pub mod event_manager;
|
||||
pub mod ipc;
|
||||
pub mod qna;
|
||||
pub mod setup;
|
||||
|
||||
pub use event::Event;
|
||||
pub use event_manager::EventManager;
|
||||
pub use qna::LLMHandle;
|
||||
10
src/main.rs
10
src/main.rs
@@ -4,13 +4,7 @@ use std::{os::unix::fs, sync::Arc};
|
||||
use tracing::{Level, info};
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
|
||||
use crate::event_manager::EventManager;
|
||||
|
||||
mod chat;
|
||||
mod event;
|
||||
mod event_manager;
|
||||
mod qna;
|
||||
mod setup;
|
||||
use robotnik::{chat, Event, EventManager, qna, setup};
|
||||
|
||||
const DEFAULT_INSTRUCT: &str =
|
||||
"You are a shady, yet helpful IRC bot. You try to give responses that can
|
||||
@@ -67,7 +61,7 @@ async fn main() -> Result<()> {
|
||||
let ev_manager = Arc::new(EventManager::new()?);
|
||||
let ev_manager_clone = Arc::clone(&ev_manager);
|
||||
ev_manager_clone
|
||||
.broadcast(&event::Event::new("Starting..."))
|
||||
.broadcast(&Event::new("Starting..."))
|
||||
.await?;
|
||||
|
||||
let mut c = chat::new(&config, &handle).await?;
|
||||
|
||||
34
src/setup.rs
34
src/setup.rs
@@ -8,65 +8,65 @@ use tracing::{info, instrument};
|
||||
// TODO: use [clap(long, short, help_heading = Some(section))]
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[command(about, version)]
|
||||
pub(crate) struct Args {
|
||||
pub struct Args {
|
||||
#[arg(short, long)]
|
||||
/// API Key for the LLM in use.
|
||||
pub(crate) api_key: Option<String>,
|
||||
pub api_key: Option<String>,
|
||||
|
||||
#[arg(short, long, default_value = "https://api.openai.com")]
|
||||
/// Base URL for the LLM API to use.
|
||||
pub(crate) base_url: Option<String>,
|
||||
pub base_url: Option<String>,
|
||||
|
||||
/// Directory to use for chroot (recommended).
|
||||
#[arg(long)]
|
||||
pub(crate) chroot_dir: Option<String>,
|
||||
pub chroot_dir: Option<String>,
|
||||
|
||||
/// Root directory for file based command structure.
|
||||
#[arg(long)]
|
||||
pub(crate) command_dir: Option<String>,
|
||||
pub command_dir: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
/// Instructions to the model on how to behave.
|
||||
pub(crate) instruct: Option<String>,
|
||||
pub instruct: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
pub(crate) model: Option<String>,
|
||||
pub model: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
/// List of IRC channels to join.
|
||||
pub(crate) channels: Option<Vec<String>>,
|
||||
pub channels: Option<Vec<String>>,
|
||||
|
||||
#[arg(short, long)]
|
||||
/// Custom configuration file location if need be.
|
||||
pub(crate) config_file: Option<PathBuf>,
|
||||
pub config_file: Option<PathBuf>,
|
||||
|
||||
#[arg(short, long, default_value = "irc.libera.chat")]
|
||||
/// IRC server.
|
||||
pub(crate) server: Option<String>,
|
||||
pub server: Option<String>,
|
||||
|
||||
#[arg(short, long, default_value = "6697")]
|
||||
/// Port of the IRC server.
|
||||
pub(crate) port: Option<String>,
|
||||
pub port: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
/// IRC Nickname.
|
||||
pub(crate) nickname: Option<String>,
|
||||
pub nickname: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
/// IRC Nick Password
|
||||
pub(crate) nick_password: Option<String>,
|
||||
pub nick_password: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
/// IRC Username
|
||||
pub(crate) username: Option<String>,
|
||||
pub username: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
/// Whether or not to use TLS when connecting to the IRC server.
|
||||
pub(crate) use_tls: Option<bool>,
|
||||
pub use_tls: Option<bool>,
|
||||
}
|
||||
|
||||
pub(crate) struct Setup {
|
||||
pub(crate) config: Config,
|
||||
pub struct Setup {
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
|
||||
Reference in New Issue
Block a user