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

Main entry point for interacting with multiple LLM providers. More...

#include <client.hpp>

Inheritance diagram for foresthub::Client:
foresthub::core::LLMClient

Public Member Functions

 Client ()
 Default constructor. Prefer Client::Create() for initialization.
void RegisterProvider (const std::shared_ptr< core::Provider > &provider)
 Register a provider instance manually.
std::string Health () const
 Check health of all registered providers.
bool SupportsModel (const core::ModelID &model) const
 Check if any registered provider supports the given model.
std::shared_ptr< core::ChatResponseChat (const core::ChatRequest &req) override
 Send a chat request, auto-selecting the provider by model ID.
const std::map< core::ProviderID, std::shared_ptr< core::Provider > > & providers () const
 Read-only access to the registered providers.

Static Public Member Functions

static std::unique_ptr< ClientCreate (const config::ClientConfig &cfg, const std::shared_ptr< core::HttpClient > &http_client=nullptr)
 Create and initialize a Client from configuration.

Detailed Description

Main entry point for interacting with multiple LLM providers.

Routes chat requests to the appropriate provider based on model ID.

Member Function Documentation

◆ Chat()

std::shared_ptr< core::ChatResponse > foresthub::Client::Chat ( const core::ChatRequest & req)
overridevirtual

Send a chat request, auto-selecting the provider by model ID.

Parameters
reqChat request with model, input, and options.
Returns
Chat response, or nullptr if no provider supports the model.

Implements foresthub::core::LLMClient.

◆ Create()

std::unique_ptr< Client > foresthub::Client::Create ( const config::ClientConfig & cfg,
const std::shared_ptr< core::HttpClient > & http_client = nullptr )
static

Create and initialize a Client from configuration.

Parameters
cfgClient configuration with provider settings.
http_clientHTTP implementation to inject into providers.
Returns
Configured client ready for use.

◆ Health()

std::string foresthub::Client::Health ( ) const

Check health of all registered providers.

Returns
Error message on failure, empty on success.

◆ RegisterProvider()

void foresthub::Client::RegisterProvider ( const std::shared_ptr< core::Provider > & provider)

Register a provider instance manually.

Parameters
providerProvider to add to the routing table; nullptr is silently ignored.

◆ SupportsModel()

bool foresthub::Client::SupportsModel ( const core::ModelID & model) const

Check if any registered provider supports the given model.

Parameters
modelModel identifier to check.
Returns
True if at least one provider supports the model.

The documentation for this class was generated from the following file: