#ifndef HUMANUS_AGENT_HUMANUS_H #define HUMANUS_AGENT_HUMANUS_H #include "base.h" #include "toolcall.h" #include "prompt.h" #include "tool/tool_collection.h" #include "tool/python_execute.h" #include "tool/terminate.h" #include "tool/puppeteer.h" #include "tool/playwright.h" #include "tool/filesystem.h" namespace humanus { /** * A versatile general-purpose agent that uses planning to solve various tasks. * * This agent extends PlanningAgent with a comprehensive set of tools and capabilities, * including Python execution, web browsing, file operations, and information retrieval * to handle a wide range of user requests. */ struct Humanus : ToolCallAgent { Humanus( const ToolCollection& available_tools = ToolCollection( // Add general-purpose tools to the tool collection { std::make_shared(), std::make_shared(), std::make_shared(), std::make_shared() } ), const std::string& tool_choice = "auto", const std::set& special_tool_names = {"terminate"}, const std::string& name = "humanus", const std::string& description = "A versatile agent that can solve various tasks using multiple tools", const std::string& system_prompt = prompt::humanus::SYSTEM_PROMPT, const std::string& next_step_prompt = prompt::humanus::NEXT_STEP_PROMPT, const std::shared_ptr& llm = nullptr, const std::shared_ptr& memory = nullptr, int max_steps = 30, int duplicate_threshold = 2 ) : ToolCallAgent( available_tools, tool_choice, special_tool_names, name, description, system_prompt, next_step_prompt, llm, memory, max_steps, duplicate_threshold ) {} std::string run(const std::string& request = "") override { memory->current_request = request; auto tmp_next_step_prompt = next_step_prompt; size_t pos = next_step_prompt.find("{current_date}"); if (pos != std::string::npos) { // %Y-%d-%m auto current_date = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(current_date); std::stringstream ss; std::tm tm_info = *std::localtime(&in_time_t); ss << std::put_time(&tm_info, "%Y-%m-%d"); std::string formatted_date = ss.str(); // YYYY-MM-DD next_step_prompt.replace(pos, 14, formatted_date); } pos = next_step_prompt.find("{current_request}"); if (pos != std::string::npos) { next_step_prompt.replace(pos, 17, request); } auto result = BaseAgent::run(request); next_step_prompt = tmp_next_step_prompt; // restore the original prompt return result; } }; } #endif // HUMANUS_AGENT_HUMANUS_H