//! Config-driven example: requires default_model_id in ~/.enact/config.yaml and providers.yaml with models.

use enact_core::providers::{ChatMessage, ChatRequest};
use enact_providers::factory::create_default_provider;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let provider = create_default_provider()?;
    let request = ChatRequest {
        messages: vec![
            ChatMessage::system("You are a concise assistant."),
            ChatMessage::user("Say hello and describe yourself in one sentence."),
        ],
        max_tokens: Some(128),
        temperature: Some(0.2),
        tools: None,
        tool_choice: None,
    };

    let response = provider.chat(request).await?;
    let text = response
        .choices
        .first()
        .and_then(|c| c.message.content.as_deref())
        .unwrap_or("");

    println!("Model: {}", provider.model());
    println!("Response: {text}");

    Ok(())
}
