5#ifndef FORESTHUB_CORE_INPUT_HPP
6#define FORESTHUB_CORE_INPUT_HPP
22using json = nlohmann::json;
33 virtual ~Input() =
default;
40 virtual void ToJson(json& j)
const = 0;
63 virtual void ToJson(json& j)
const = 0;
81 void ToJson(json& j)
const override { j = json{{
"value",
text}}; }
87 std::vector<std::shared_ptr<InputItem>>
items;
93 explicit InputItems(
const std::shared_ptr<InputItem>& item) {
items.push_back(item); }
96 void PushBack(
const std::shared_ptr<InputItem>& item) {
items.push_back(item); }
104 for (
const auto& item :
items) {
107 item->ToJson(item_j);
111 j.push_back(std::move(item_j));
116 using Iterator = std::vector<std::shared_ptr<InputItem>>::iterator;
118 using ConstIterator = std::vector<std::shared_ptr<InputItem>>::const_iterator;
135 template <
typename... Args>
137 items.insert(std::forward<Args>(args)...);
144inline std::shared_ptr<InputItems>
AsInputItems(
const std::shared_ptr<Input>& input) {
146 return std::make_shared<InputItems>();
149 switch (input->GetInputType()) {
151 return std::static_pointer_cast<InputItems>(input);
153 auto new_list = std::make_shared<InputItems>();
154 new_list->PushBack(std::static_pointer_cast<InputString>(input));
159 return std::make_shared<InputItems>();
Wrapper for nlohmann/json that works around abs macro conflicts.
Core abstractions: requests, responses, tools, input types, and provider interface.
std::shared_ptr< InputItems > AsInputItems(const std::shared_ptr< Input > &input)
Normalize input to InputItems.
Definition input.hpp:144
InputItemType
Type discriminator for InputItem subclasses.
Definition input.hpp:44
@ kString
Plain text (InputString).
Definition input.hpp:45
@ kToolResult
Tool execution result (ToolResult).
Definition input.hpp:47
@ kToolCall
Tool call request from the model (ToolCallRequest).
Definition input.hpp:46
InputType
Type discriminator for Input subclasses.
Definition input.hpp:25
@ kString
Single text string.
Definition input.hpp:26
@ kItems
Ordered list of conversation items.
Definition input.hpp:27
Top-level namespace for the ForestHub SDK.