Files
owlen/examples/basic_chat.rs
vikingowl 4d7ad2c330 Refactor codebase for consistency and readability
- Standardize array and vector formatting for clarity.
- Adjust spacing and indentation in examples and TUI code.
- Ensure proper newline usage across files (e.g., LICENSE, TOML files, etc.).
- Simplify `.to_string()` and `.ok()` calls for brevity.
2025-10-05 02:31:53 +02:00

31 lines
999 B
Rust

// This example demonstrates a basic chat interaction without the TUI.
use owlen_core::model::Model;
use owlen_core::provider::Provider;
use owlen_core::session::Session;
use owlen_ollama::OllamaProvider; // Assuming you have an Ollama provider
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// This example requires a running Ollama instance.
// Make sure you have a model available, e.g., `ollama pull llama2`
let provider = OllamaProvider;
let model = Model::new("llama2"); // Change to a model you have
let mut session = Session::new("basic-chat-session");
println!("Starting basic chat with model: {}", model.name);
let user_message = "What is the capital of France?";
session.add_message("user", user_message);
println!("User: {}", user_message);
// Send the chat to the provider
let response = provider.chat(&session, &model).await?;
session.add_message("bot", &response);
println!("Bot: {}", response);
Ok(())
}