use std::env;
use anyhow::Result;
use swarms_rs::{llm::provider::openai::OpenAI, structs::agent::Agent};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
#[tokio::main]
async fn main() -> Result<()> {
dotenv::dotenv().ok();
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
.with(
tracing_subscriber::fmt::layer()
.with_line_number(true)
.with_file(true),
)
.init();
let base_url = env::var("DEEPSEEK_BASE_URL").unwrap();
let api_key = env::var("DEEPSEEK_API_KEY").unwrap();
let client = OpenAI::from_url(base_url, api_key).set_model("deepseek-chat");
let agent = client
.agent_builder()
.system_prompt("You are a helpful assistant.")
.agent_name("SwarmsAgent")
.user_name("User")
.enable_autosave()
.max_loops(1)
.save_sate_path("./temp/agent1_state.json") .enable_plan("Split the task into subtasks.".to_owned())
.build();
let response = agent
.run("What is the meaning of life?".to_owned())
.await
.unwrap();
println!("{response}");
Ok(())
}