use std::env;

use anyhow::Result;
use meridian::llms::{
    anthropic::messages::{AnthropicMessage, AnthropicMessageContent},
    open_ai::messages::OpenAIMessage,
};

pub fn setup_test_env() -> Result<()> {
    dotenvy::dotenv().unwrap();

    let anthropic_api_key = std::env::var("ANTHROPIC_API_KEY").unwrap();
    let openai_api_key = std::env::var("OPENAI_API_KEY").unwrap();

    if anthropic_api_key.is_empty() || openai_api_key.is_empty() {
        eprintln!("ANTHROPIC_API_KEY or OPENAI_API_KEY is not set");
        return Err(anyhow::anyhow!(
            "ANTHROPIC_API_KEY or OPENAI_API_KEY is not set"
        ));
    }

    Ok(())
}

pub fn can_run_openai_test() -> bool {
    env::var("OPENAI_API_KEY").is_ok()
}

pub fn can_run_anthropic_test() -> bool {
    env::var("ANTHROPIC_API_KEY").is_ok()
}

pub struct PromptFixture {
    prompts: Vec<String>,
}

impl PromptFixture {
    pub fn open_ai_user_messages() -> Vec<OpenAIMessage> {
        vec![OpenAIMessage::User {
            content: "hello world".to_string(),
        }]
    }

    pub fn anthropic_user_messages() -> Vec<AnthropicMessage> {
        vec![AnthropicMessage::User {
            content: vec![AnthropicMessageContent::Text {
                text: "hello world".to_string(),
            }],
            tool_use_id: None,
        }]
    }
}
