From 7d8564cafb45afc4bccb666a310615b164800a9a Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 26 Oct 2023 16:42:54 +0800 Subject: feat: support multi bots and custom url (#150) --- src/repl/handler.rs | 8 ++++---- src/repl/mod.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/repl') diff --git a/src/repl/handler.rs b/src/repl/handler.rs index 2057b8b..53cdd98 100644 --- a/src/repl/handler.rs +++ b/src/repl/handler.rs @@ -1,4 +1,4 @@ -use crate::client::ChatGptClient; +use crate::client::Client; use crate::config::SharedConfig; use crate::print_now; use crate::render::render_stream; @@ -26,7 +26,7 @@ pub enum ReplCmd { #[allow(clippy::module_name_repetitions)] pub struct ReplCmdHandler { - client: ChatGptClient, + client: Box, config: SharedConfig, reply: RefCell, abort: SharedAbortSignal, @@ -35,7 +35,7 @@ pub struct ReplCmdHandler { impl ReplCmdHandler { #[allow(clippy::unnecessary_wraps)] pub fn init( - client: ChatGptClient, + client: Box, config: SharedConfig, abort: SharedAbortSignal, ) -> Result { @@ -59,7 +59,7 @@ impl ReplCmdHandler { let wg = WaitGroup::new(); let ret = render_stream( &input, - &self.client, + self.client.as_ref(), &self.config, true, self.abort.clone(), diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 2e68528..ce640f8 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -9,7 +9,7 @@ pub use self::abort::*; pub use self::handler::*; pub use self::init::Repl; -use crate::client::ChatGptClient; +use crate::client::Client; use crate::config::SharedConfig; use crate::print_now; use crate::term; @@ -35,7 +35,7 @@ pub const REPL_COMMANDS: [(&str, &str); 13] = [ ]; impl Repl { - pub fn run(&mut self, client: ChatGptClient, config: SharedConfig) -> Result<()> { + pub fn run(&mut self, client: Box, config: SharedConfig) -> Result<()> { let abort = AbortSignal::new(); let handler = ReplCmdHandler::init(client, config, abort.clone())?; print_now!("Welcome to aichat {}\n", env!("CARGO_PKG_VERSION")); -- cgit v1.2.3