#ifndef HUMANUS_TOOL_CREATE_CHAT_COMPLETION_H #define HUMANUS_TOOL_CREATE_CHAT_COMPLETION_H #include "base.h" #include #include #include #include #include namespace humanus { struct CreateChatCompletion : BaseTool { inline static const std::string name_ = "create_chat_completion"; inline static const std::string description_ = "Creates a structured completion with specified output formatting."; // 类型映射表,用于JSON schema inline static std::unordered_map type_mapping = { {"string", "string"}, {"int", "integer"}, {"float", "number"}, {"double", "number"}, {"bool", "boolean"}, {"object", "object"}, {"array", "array"} }; std::string response_type; std::vector required; CreateChatCompletion(const std::string& response_type = "string", const std::vector& required = {"response"}) : BaseTool(name_, description_, json::object()), response_type(response_type), required(required) { parameters = _build_parameters(); } json _build_parameters() const; json _create_type_schema(const std::string& type_hint) const; json _get_type_info(const std::string& type_hint) const; json _create_union_schema(const std::vector& types) const; ToolResult execute(const json& args) override; }; } #endif // HUMANUS_TOOL_CREATE_CHAT_COMPLETION_H