1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::path::PathBuf;

use chatgpt::chatbot::Chatbot;
use chatgpt::config::Config;
use futures::StreamExt;

#[tokio::main]
async fn main() {
    std::env::set_var("RUST_LOG", "info");
    pretty_env_logger::init();
    let config_file = PathBuf::from(std::env::var("HOME").unwrap()).join(".config/chatgpt/config.json");
    let config = Config::from_file(&config_file);
    let mut bot = Chatbot::new(config).await;
    let mut response = bot.ask_stream("Explain quantum physics.").await;
    while let Some(Ok(response)) = response.next().await {
        println!("{response}");
    }
}