AiProviders.h header

#include <ew/app/AiProviders.h>

Namespace ew::app

Functions

bool ew::app::ai::cloudFeaturesAvailable()

Whether this build contains any networking at all – true when EW_ENABLE_CLOUD was on.

For messages and menu state, so the UI can say "this build has no network features" rather than "your endpoint is misconfigured". Those two are indistinguishable from isConfigured() alone, and telling someone to check settings that cannot help would be worse than saying nothing.

AiEmbeddingResponse ew::app::ai::fetchEmbeddings(const AiSettings &settings, const std::vector< QString > &texts)

Embeds texts using settings' embeddings endpoint.

Same seam and same two definitions as makeAiProvider. Chat has an interface to express absence through; these three are free functions, so absence comes back as an ordinary failed result – which is what an unreachable endpoint produces anyway, so no caller needs a new branch.

AiImageResult ew::app::ai::generateImage(const AiSettings &settings, const QString &prompt, const QString &size={})

Generates an image for prompt at an optional size using settings' image endpoint.

AiSpeechResult ew::app::ai::generateSpeech(const AiSettings &settings, const QString &text)

Synthesizes text to audio using settings' speech endpoint.

std::unique_ptr< AiProvider > ew::app::ai::makeAiProvider(const AiSettings &settings)

Builds the AI provider this build ships with, configured from settings. NEVER null.

THIS IS THE SEAM THAT KEEPS #ifdef OUT OF THE UI (docs/LOCAL_ENGINEERING_RUN.md section 4.1). It is DECLARED here in libs/app, which has no networking, and DEFINED in exactly one of two places depending on how the build was configured:

  • libs/cloud when EW_ENABLE_CLOUD is on – the real HTTP-backed provider;
  • libs/app/src/ai/NoCloudAiProviders.cpp when it is off – a provider that is never configured and whose send() returns an error.

CMake compiles whichever one applies, so a caller writes the same code either way and the offline build genuinely does not contain the networking rather than merely refusing to use it.

It returns a provider rather than null on purpose. "No AI available" is a state the UI has always had to render, because the provider is bring-your-own and unconfigured by default – so expressing absence through isConfigured(), which every caller already respects, costs nothing. A null contract would instead push a null check into every worker-thread call site, where forgetting one is a crash rather than a missing feature.