fix compilation error on Windows
parent
be606c1020
commit
c8a9056e4a
|
@ -1,6 +1,30 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project(humanus.cpp VERSION 0.1.0)
|
||||
|
||||
set(CMAKE_WARN_UNUSED_CLI YES)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT})
|
||||
|
||||
if (WIN32)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/utf-8>")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/utf-8>")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/bigobj>")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
|
||||
add_compile_options(/wd4244 /wd4267)
|
||||
endif()
|
||||
|
||||
# Set C++ standard
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
|
11
agent/base.h
11
agent/base.h
|
@ -4,6 +4,11 @@
|
|||
#include "../llm.h"
|
||||
#include "../schema.h"
|
||||
#include "../logger.h"
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
namespace humanus {
|
||||
|
||||
|
@ -103,7 +108,7 @@ struct BaseAgent : std::enable_shared_from_this<BaseAgent> {
|
|||
step_result = step();
|
||||
} catch (const std::exception& e) {
|
||||
logger->error("Error executing step " + std::to_string(current_step) + ": " + std::string(e.what()));
|
||||
state = AgentState::ERROR;
|
||||
state = AgentState::ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -116,7 +121,7 @@ struct BaseAgent : std::enable_shared_from_this<BaseAgent> {
|
|||
if (current_step >= max_steps) {
|
||||
results.push_back("Terminated: Reached max steps (" + std::to_string(max_steps) + ")");
|
||||
}
|
||||
if (state == AgentState::ERROR) {
|
||||
if (state == AgentState::ERR) {
|
||||
results.push_back("Terminated: Agent state is " + agent_state_map[state]);
|
||||
} else {
|
||||
state = AgentState::IDLE; // FINISHED -> IDLE
|
||||
|
@ -182,6 +187,6 @@ struct BaseAgent : std::enable_shared_from_this<BaseAgent> {
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace humanus
|
||||
|
||||
#endif // HUMANUS_AGENT_BASE_H
|
||||
|
|
|
@ -142,7 +142,7 @@ std::string ToolCallAgent::execute_tool(ToolCall tool_call) {
|
|||
_handle_special_tool(name, result);
|
||||
|
||||
return observation;
|
||||
} catch (const json::exception& e) {
|
||||
} catch (const json::exception& /* e */) {
|
||||
std::string error_msg = "Error parsing arguments for " + name + ": Invalid JSON format";
|
||||
logger->error(
|
||||
"📝 Oops! The arguments for '" + name + "' don't make sense - invalid JSON"
|
||||
|
|
5
config.h
5
config.h
|
@ -18,8 +18,9 @@ static std::filesystem::path get_project_root() {
|
|||
return std::filesystem::path(__FILE__).parent_path();
|
||||
}
|
||||
|
||||
inline const std::filesystem::path PROJECT_ROOT = get_project_root();
|
||||
inline const std::filesystem::path WORKSPACE_ROOT = PROJECT_ROOT / "workspace";
|
||||
// Windows环境下使用静态变量
|
||||
static const std::filesystem::path PROJECT_ROOT = get_project_root();
|
||||
static const std::filesystem::path WORKSPACE_ROOT = PROJECT_ROOT / "workspace";
|
||||
|
||||
struct LLMSettings {
|
||||
std::string model;
|
||||
|
|
|
@ -58,7 +58,7 @@ std::string PlanningFlow::execute(const std::string& input) {
|
|||
result += step_result + "\n";
|
||||
|
||||
// Check if agent wants to terminate
|
||||
if (executor->state == AgentState::FINISHED || executor->state == AgentState::ERROR) {
|
||||
if (executor->state == AgentState::FINISHED || executor->state == AgentState::ERR) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "logger.h"
|
||||
#include "config.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <filesystem>
|
||||
|
||||
namespace humanus {
|
||||
|
||||
|
|
2
mcp
2
mcp
|
@ -1 +1 @@
|
|||
Subproject commit 7f9862f91ca82118f31834570ee409381574eba0
|
||||
Subproject commit 5e9ff48b070a11ba20529feb22c68d0e9ef46f3d
|
|
@ -6,7 +6,7 @@ std::map<AgentState, std::string> agent_state_map = {
|
|||
{AgentState::IDLE, "IDLE"},
|
||||
{AgentState::RUNNING, "RUNNING"},
|
||||
{AgentState::FINISHED, "FINISHED"},
|
||||
{AgentState::ERROR, "ERROR"}
|
||||
{AgentState::ERR, "ERROR"}
|
||||
};
|
||||
|
||||
} // namespace humanus
|
7
schema.h
7
schema.h
|
@ -2,6 +2,10 @@
|
|||
#define HUMANUS_SCHEMA_H
|
||||
|
||||
#include "mcp_message.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
namespace humanus {
|
||||
|
||||
|
@ -12,9 +16,10 @@ enum class AgentState {
|
|||
IDLE = 0,
|
||||
RUNNING = 1,
|
||||
FINISHED = 2,
|
||||
ERROR = 3
|
||||
ERR = 3 // Don't use ERROR
|
||||
};
|
||||
|
||||
// 定义全局map
|
||||
extern std::map<AgentState, std::string> agent_state_map;
|
||||
|
||||
struct Function {
|
||||
|
|
Loading…
Reference in New Issue