mod api; use api::OllamaAPI; use iced::{ futures::StreamExt, widget::{button, column, container, row, scrollable, text}, window::{self}, Application, Command, Settings, Theme, }; enum UI { Loading, Loaded, } #[derive(Debug, Clone)] enum UIMessage { LoadDone, } #[tokio::main] async fn main() -> anyhow::Result<()> { println!("Making request"); let api = OllamaAPI::create("http://localhost:11434")?; let mut chat = api.create_chat("dolphin-mixtral"); chat.send_system("You are a bot that only replies with \"Hello\" and nothing else. You must never reply with anything other than \"Hello\""); chat.send_user("Who are you?"); // println!("{}", amogus.get().await?); let mut a = chat.complete().await?; while let Some(v) = a.next().await { println!("GOT = {:?}", v); } UI::run(Settings { window: window::Settings { size: (720, 480), ..window::Settings::default() }, ..Settings::default() })?; Ok(()) } impl Application for UI { type Executor = iced::executor::Default; type Message = UIMessage; type Theme = Theme; type Flags = (); fn new(_flags: Self::Flags) -> (Self, iced::Command) { ( UI::Loading, Command::perform(async {}, |_| UIMessage::LoadDone), ) } fn title(&self) -> String { String::from("Hello World") } fn update(&mut self, message: Self::Message) -> iced::Command { match message { UIMessage::LoadDone => { *self = UI::Loaded; Command::none() } } } fn view(&self) -> iced::Element<'_, Self::Message, iced::Renderer> { let content = match self { UI::Loading => row![text("This is amogus sussy baka!")], UI::Loaded => row![button(text("Hello Wordl!")).on_press(UIMessage::LoadDone)], }; let amogus = text("Hello!"); scrollable( container(column![content, amogus].spacing(20).max_width(480)) .padding(40) .center_x(), ) .into() } fn theme(&self) -> Self::Theme { Theme::Dark } }