ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (c) 2026 ForestHub. All rights reserved.
3// For commercial licensing, visit https://github.com/ForestHubAI/fh-sdk
4
5#ifndef FORESTHUB_CLIENT_HPP
6#define FORESTHUB_CLIENT_HPP
7
10
11#include <map>
12#include <memory>
13#include <string>
14
20
21namespace foresthub {
22
26class Client : public core::LLMClient {
27public:
30
35 static std::unique_ptr<Client> Create(const config::ClientConfig& cfg,
36 const std::shared_ptr<core::HttpClient>& http_client = nullptr);
37
40 void RegisterProvider(const std::shared_ptr<core::Provider>& provider);
41
44 std::string Health() const;
45
49 bool SupportsModel(const core::ModelID& model) const;
50
54 std::shared_ptr<core::ChatResponse> Chat(const core::ChatRequest& req) override;
55
57 const std::map<core::ProviderID, std::shared_ptr<core::Provider>>& providers() const { return providers_; }
58
59private:
60 std::map<core::ProviderID, std::shared_ptr<core::Provider>> providers_;
61
63 std::shared_ptr<core::Provider> InferProvider(const core::ModelID& model) const;
64};
65
66} // namespace foresthub
67
68#endif // FORESTHUB_CLIENT_HPP
bool SupportsModel(const core::ModelID &model) const
Check if any registered provider supports the given model.
std::shared_ptr< core::ChatResponse > Chat(const core::ChatRequest &req) override
Send a chat request, auto-selecting the provider by model ID.
static std::unique_ptr< Client > Create(const config::ClientConfig &cfg, const std::shared_ptr< core::HttpClient > &http_client=nullptr)
Create and initialize a Client from configuration.
Client()
Default constructor. Prefer Client::Create() for initialization.
std::string Health() const
Check health of all registered providers.
const std::map< core::ProviderID, std::shared_ptr< core::Provider > > & providers() const
Read-only access to the registered providers.
Definition client.hpp:57
void RegisterProvider(const std::shared_ptr< core::Provider > &provider)
Register a provider instance manually.
Abstract interface for LLM chat operations.
Definition provider.hpp:21
Client and provider configuration types.
ChatRequest and ChatResponse types with fluent builder API.
Abstract HTTP client interface and response type.
Model metadata and capability identifiers.
std::string ModelID
Unique identifier for an LLM model.
Definition model.hpp:23
LLM provider implementations.
Top-level namespace for the ForestHub SDK.
LLMClient and Provider interfaces for chat operations.
Top-level client configuration controlling which providers are created.
Definition config.hpp:48
Chat completion request sent to an LLM provider.
Definition types.hpp:39