config file, bugfixes

This commit is contained in:
leach
2025-08-15 15:41:32 -04:00
parent b171a6b2b2
commit 7d237f692c
7 changed files with 364 additions and 29 deletions

View File

@@ -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);
}