ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
foresthub::core Namespace Reference

Core abstractions: requests, responses, tools, input types, and provider interface. More...

Namespaces

namespace  capability
 Model capability identifiers.

Classes

struct  ChatRequest
 Chat completion request sent to an LLM provider. More...
struct  ChatResponse
 Chat completion response from an LLM provider. More...
class  ExternalTool
 Tool with description and parameter schema, handled outside the LLM provider. More...
class  ExternalToolBase
 Base implementation of ExternalTool with name, description, and parameters. More...
class  FunctionTool
 ExternalTool with a C++ callback for execution. More...
class  HttpClient
 Abstract interface for HTTP operations. More...
struct  HttpResponse
 Simple HTTP response container. More...
class  Input
 Abstract base for all input types. More...
class  InputItem
 Abstract base for items inside an InputItems list. More...
class  InputItems
 An ordered list of InputItem elements. More...
class  InputString
 A string that acts as both top-level Input and InputItem. More...
class  InternalToolCall
 Represents a tool call initiated internally by the model. More...
class  LLMClient
 Abstract interface for LLM chat operations. More...
struct  ModelInfo
 Metadata about an LLM model. More...
struct  Options
 Model-specific generation options. More...
class  Provider
 Extended LLM interface with health checks and model discovery. More...
struct  ResponseFormat
 Structured output format with JSON schema constraints. More...
class  Tool
 Base interface for all tools. More...
class  ToolCallRequest
 Request from the model to call a tool. More...
class  ToolResult
 Output of an executed tool. More...
class  WebSearch
 Built-in web search tool. More...
class  WebSearchToolCall
 Log entry for a web search invocation. More...

Typedefs

using ProviderID = std::string
 Unique identifier for an LLM provider.
using ModelID = std::string
 Unique identifier for an LLM model.
using ModelCapability = std::string
 Capability string describing what a model can do.
using FileID = std::string
 Unique identifier for an uploaded file.

Enumerations

enum class  InputType : uint8_t { kString , kItems }
 Type discriminator for Input subclasses. More...
enum class  InputItemType : uint8_t { kString , kToolCall , kToolResult }
 Type discriminator for InputItem subclasses. More...
enum class  ToolType : uint8_t { kFunction , kWebSearch , kHandoff }
 Type discriminator for Tool subclasses. More...

Functions

std::shared_ptr< InputItemsAsInputItems (const std::shared_ptr< Input > &input)
 Normalize input to InputItems.
void to_json (json &j, const Options &opts)
 Serialize Options to JSON.
void from_json (const json &j, Options &opts)
 Deserialize Options from JSON.
void to_json (json &j, const ResponseFormat &format)
 Serialize ResponseFormat to JSON.
void from_json (const json &j, ResponseFormat &format)
 Deserialize ResponseFormat from JSON.
void to_json (json &j, const std::shared_ptr< InputItem > &item)
 Serialize an InputItem (dispatches by subtype; nullptr produces JSON null).
void to_json (json &j, const std::shared_ptr< Tool > &tool)
 Serialize a Tool (dispatches by subtype).
void to_json (json &j, const ChatRequest &req)
 Serialize ChatRequest to JSON.
void from_json (const json &j, ChatRequest &req)
 Deserialize ChatRequest from JSON.
void from_json (const json &j, ChatResponse &resp)
 Deserialize ChatResponse from JSON.
template<typename T, typename R>
std::shared_ptr< FunctionToolNewFunctionTool (std::string name, std::string description, const json &schema, const std::function< R(T)> &handler)
 Create a FunctionTool with type-safe argument parsing.

Detailed Description

Core abstractions: requests, responses, tools, input types, and provider interface.

Enumeration Type Documentation

◆ InputItemType

enum class foresthub::core::InputItemType : uint8_t
strong

Type discriminator for InputItem subclasses.

Enumerator
kString 

Plain text (InputString).

kToolCall 

Tool call request from the model (ToolCallRequest).

kToolResult 

Tool execution result (ToolResult).

◆ InputType

enum class foresthub::core::InputType : uint8_t
strong

Type discriminator for Input subclasses.

Enumerator
kString 

Single text string.

kItems 

Ordered list of conversation items.

◆ ToolType

enum class foresthub::core::ToolType : uint8_t
strong

Type discriminator for Tool subclasses.

Enumerator
kFunction 

User-defined function tool with C++ callback.

kWebSearch 

Built-in web search tool.

kHandoff 

Agent handoff tool.

Function Documentation

◆ AsInputItems()

std::shared_ptr< InputItems > foresthub::core::AsInputItems ( const std::shared_ptr< Input > & input)
inline

Normalize input to InputItems.

Parameters
inputInput to normalize (string or items); nullptr returns an empty InputItems.
Returns
InputItems containing the input content.

◆ NewFunctionTool()

template<typename T, typename R>
std::shared_ptr< FunctionTool > foresthub::core::NewFunctionTool ( std::string name,
std::string description,
const json & schema,
const std::function< R(T)> & handler )

Create a FunctionTool with type-safe argument parsing.

Template Parameters
TArgument struct type, deserialized from JSON via from_json(). T's from_json() MUST NOT throw — on no-exception platforms a throwing from_json() causes undefined behavior (typically abort). Use j.value() with defaults, not j.at().
RReturn type of the handler, convertible to nlohmann::json.
Parameters
nameTool name visible to the LLM in the tool schema.
descriptionHuman-readable description sent to the LLM.
schemaJSON schema for tool parameters.
handlerCallback that receives parsed arguments and returns a result.
Returns
Configured FunctionTool ready for use with Agent::AddTool() or ChatRequest::AddTool().

◆ to_json()

void foresthub::core::to_json ( json & j,
const std::shared_ptr< InputItem > & item )

Serialize an InputItem (dispatches by subtype; nullptr produces JSON null).

Parameters
itemInputItem to serialize, or nullptr for null.