config file, bugfixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::core::{
|
||||
create_client, get_provider_for_model, provider::get_all_models, provider::get_supported_models,
|
||||
provider::is_model_supported, ChatClient, Session,
|
||||
@@ -12,22 +13,24 @@ pub struct ChatCLI {
|
||||
current_model: Option<String>,
|
||||
display: Display,
|
||||
input: InputHandler,
|
||||
config: Config,
|
||||
}
|
||||
|
||||
impl ChatCLI {
|
||||
pub fn new(session: Session) -> Result<Self> {
|
||||
pub fn new(session: Session, config: Config) -> Result<Self> {
|
||||
Ok(Self {
|
||||
session,
|
||||
client: None,
|
||||
current_model: None,
|
||||
display: Display::new(),
|
||||
input: InputHandler::new()?,
|
||||
config,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_client(&mut self) -> Result<&ChatClient> {
|
||||
if self.client.is_none() || self.current_model.as_ref() != Some(&self.session.model) {
|
||||
let client = create_client(&self.session.model)?;
|
||||
let client = create_client(&self.session.model, &self.config)?;
|
||||
self.current_model = Some(self.session.model.clone());
|
||||
self.client = Some(client);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user