forgeant docs-test-0
Build LLM-powered agents in C++
Loading...
Searching...
No Matches
content.hpp
Go to the documentation of this file.
1#ifndef FORGEANT_TYPES_CONTENT_HPP
2#define FORGEANT_TYPES_CONTENT_HPP
3
5#include <string>
6#include <variant>
7
8namespace forgeant {
9
10struct TextBlock {
11 std::string text;
12
13 bool operator==(const TextBlock&) const = default;
14};
15
17 std::string id;
18 std::string name;
20
22 ToolUseBlock(std::string id, std::string name, Json input);
23
24 ToolUseBlock(const ToolUseBlock&) = default;
25 ToolUseBlock(ToolUseBlock&&) noexcept = default;
26 ToolUseBlock& operator=(const ToolUseBlock&) = default;
27 ToolUseBlock& operator=(ToolUseBlock&&) noexcept = default;
28 ~ToolUseBlock() = default;
29
30 bool operator==(const ToolUseBlock& other) const {
31 return id == other.id && name == other.name && input == other.input;
32 }
33};
34
36 std::string tool_use_id;
37 std::string content;
38 bool is_error = false;
39
40 bool operator==(const ToolResultBlock&) const = default;
41};
42
43using ContentBlock = std::variant<TextBlock, ToolUseBlock, ToolResultBlock>;
44
45void to_json(Json& j, const TextBlock& block);
46void from_json(const Json& j, TextBlock& block);
47
48void to_json(Json& j, const ToolUseBlock& block);
49void from_json(const Json& j, ToolUseBlock& block);
50
51void to_json(Json& j, const ToolResultBlock& block);
52void from_json(const Json& j, ToolResultBlock& block);
53
54void to_json(Json& j, const ContentBlock& block);
55void from_json(const Json& j, ContentBlock& block);
56
57} // namespace forgeant
58
59#endif // FORGEANT_TYPES_CONTENT_HPP
Definition json.hpp:27
Definition agent.hpp:25
void to_json(Json &j, const TextBlock &block)
void from_json(const Json &j, TextBlock &block)
std::variant< TextBlock, ToolUseBlock, ToolResultBlock > ContentBlock
Definition content.hpp:43
Definition content.hpp:10
bool operator==(const TextBlock &) const =default
std::string text
Definition content.hpp:11
Definition content.hpp:35
bool is_error
Definition content.hpp:38
bool operator==(const ToolResultBlock &) const =default
std::string content
Definition content.hpp:37
std::string tool_use_id
Definition content.hpp:36
Definition content.hpp:16
std::string name
Definition content.hpp:18
ToolUseBlock(std::string id, std::string name, Json input)
std::string id
Definition content.hpp:17
Json input
Definition content.hpp:19
ToolUseBlock(ToolUseBlock &&) noexcept=default
ToolUseBlock(const ToolUseBlock &)=default