euxis-inference-cpp¶
C++23 local inference engine — llama.cpp integration, Ollama client, model registry, quality gate.
README¶
euxis::inference
LLM backends for euxis: local engines (llama.cpp, Ollama), HTTP-streaming
providers (Anthropic Claude, OpenAI, Gemini) implementing
IStreamingProvider, a model registry, and Anthropic
prompt-cache discipline helpers.
Contents¶
Quick start — stream a Claude response via SSE
Examples — local + remote + cache-control
Install¶
add_subdirectory(libs/inference)
target_link_libraries(my_app PRIVATE euxis-inference-cpp)
Quick start¶
#include <iostream>
#include "euxis/inference/claude_streaming.hpp"
int main() {
using namespace euxis::inference;
using euxis::runtime::DeltaKind;
ClaudeStreamingConfig cfg; // reads ANTHROPIC_API_KEY by default
cfg.model = "claude-sonnet-4-6";
ClaudeStreamingProvider provider{cfg};
std::string assembled;
for (auto&& d : provider.execute_stream("claude-sonnet-4-6", "Summarise the auth module.")) {
if (d.kind == DeltaKind::TextFragment) {
assembled += d.text;
std::cout << d.text << std::flush;
}
}
std::cout << "\n(assembled " << assembled.size() << " bytes)\n";
}
Requires a toolchain with <generator> — see Toolchain notes.
Public surface¶
Header |
What it owns |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
Anthropic prompt-cache discipline — marker placement on last system + last user message; idempotent re-application |
|
|
|
|
|
|
Examples¶
Local llama.cpp inference¶
#include "euxis/inference/llama_engine.hpp"
LlamaEngine engine{/*model_path=*/"models/llama-3-8b-q4.gguf"};
const auto out = engine.generate("llama-3-8b", "Hi", /*params=*/{});
Quality-gate a candidate response¶
#include "euxis/inference/quality_gate.hpp"
QualityGate gate;
const auto score = gate.score(candidate_text, /*context=*/prompt);
if (score.quality < 0.7) reject();
Anthropic prompt-cache markers¶
#include "euxis/inference/cache_control.hpp"
auto messages = build_messages(...);
apply_cache_control(messages); // idempotent; safe to call repeatedly
Toolchain notes¶
IStreamingProvider and the three streaming-provider classes are gated by EUXIS_HAS_STD_GENERATOR (set when __cpp_lib_generator >= 202207L). GCC 14’s libstdc++ ships <generator>; Apple Clang 21 / Homebrew LLVM 22 libc++ does not as of 2026-06. On unsupported toolchains the streaming symbols compile out and the related tests skip cleanly.
License¶
AGPL-3.0-only. See LICENSE.