AiProvider.h header

#include <ew/app/AiProvider.h>

Namespace ew::app

AiProvider class

class ew::app::AiProvider

The seam every AI feature talks to: send a chat request, get a reply (or an error). Concrete providers back it with an HTTP call to a real model or, for tests and offline use, a deterministic mock. Held via pointer so a feature can be given any provider.

Members

ew::app::AiProvider::AiProvider()=default

Defaulted.

virtual ew::app::AiProvider::~AiProvider()=default

Defaulted.

ew::app::AiProvider::AiProvider(const AiProvider &)=delete

Not copyable.

ew::app::AiProvider::AiProvider(AiProvider &&)=delete

Not movable.

AiProvider & ew::app::AiProvider::operator=(const AiProvider &)=delete

Not copyable.

AiProvider & ew::app::AiProvider::operator=(AiProvider &&)=delete

Not movable.

virtual AiResponse ew::app::AiProvider::send(const AiRequest &request)=0

Sends request to the model and returns its reply, or an AiResponse carrying an error.

virtual bool ew::app::AiProvider::isConfigured() const =0

True when the provider is ready to send (configured with an endpoint/model, or always for a mock).

AiSettings struct

struct ew::app::AiSettings

How to reach a language model: the chat-completions endpoint URL, the API key (a Bearer token, empty for a keyless local server), the model name, and the default sampling temperature. Supplied from settings and never hard-coded, so the same build works against a hosted API or a local server. Cloud endpoints send project content off-device, so the UI should treat a configured cloud endpoint as opt-in for sensitive work.

Members

QString ew::app::AiSettings::endpoint

The chat-completions endpoint, e.g. "https://api.openai.com/v1/chat/completions" or a local "http://localhost:11434/v1/chat/completions".

QString ew::app::AiSettings::apiKey

The API key sent as a Bearer token; empty when the endpoint needs none (a local server).

QString ew::app::AiSettings::model

The model name to request.

double ew::app::AiSettings::temperature = 0.7

The default sampling temperature for requests that do not set their own.

bool ew::app::AiSettings::redactOnCloud = false

When true, codex entity names are replaced with opaque placeholders before a request is sent to a non-local (cloud) endpoint, and restored in the reply, so sensitive names are not sent off-device. Off by default (it reduces the model's context).

QString ew::app::AiSettings::embeddingsEndpoint

The OpenAI-compatible embeddings endpoint, e.g. "https://api.openai.com/v1/embeddings" or a local server's. Optional – set only to enable semantic (meaning-based) codex retrieval; the API key above is reused. Empty means embeddings features are off.

QString ew::app::AiSettings::embeddingsModel

The embeddings model to request (e.g. "text-embedding-3-small"). Paired with embeddingsEndpoint.

QString ew::app::AiSettings::imageEndpoint

The OpenAI-compatible images/generations endpoint, e.g. "https://api.openai.com/v1/images/generations". Optional – set only to enable image generation; the API key above is reused. Empty means image features are off.

QString ew::app::AiSettings::imageModel

The image model to request (e.g. "gpt-image-1", "dall-e-3"). Paired with imageEndpoint.

QString ew::app::AiSettings::speechEndpoint

The OpenAI-compatible text-to-speech endpoint, e.g. "https://api.openai.com/v1/audio/speech". Optional – set only to enable voice generation; the API key above is reused.

QString ew::app::AiSettings::speechModel

The text-to-speech model to request (e.g. "tts-1"). Paired with speechEndpoint.

QString ew::app::AiSettings::speechVoice

The voice to use for text-to-speech (e.g. "alloy"); empty leaves it to the provider's default.

int ew::app::AiSettings::tokenBudget = 0

A cap on the tokens spent per session across all AI features combined; 0 means no limit. The UI tracks usage against it (see AiUsage) and warns once a session passes it.

bool ew::app::AiSettings::isConfigured() const

True once there is enough to make a chat request: an endpoint and a model.

bool ew::app::AiSettings::hasEmbeddings() const

True once semantic retrieval can run: an embeddings endpoint and model are set.

bool ew::app::AiSettings::hasImageGen() const

True once image generation can run: an image endpoint and model are set.

bool ew::app::AiSettings::hasSpeech() const

True once voice generation can run: a speech endpoint and model are set (the voice is optional).