feat: testSystemAi accepts draft config; list+pull models (v0.6.0)

`testSystemAi` now takes optional provider/endpoint/model/
apiKeyEnv/privacyMode params; the editor passes form values so
Test Connection works before Save. New `listSystemAiModels`
fetches the provider's `/v1/models` listing, `pullSystemAiModel`
calls Ollama's `/api/pull` synchronously.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-05-07 14:02:43 +02:00
parent 8798119903
commit f04da40751
5 changed files with 570 additions and 16 deletions

View file

@ -46,6 +46,9 @@ typedef ChannelStatusResponse = pb.ChannelStatusResponse;
typedef ChannelEntry = pb.ChannelEntry;
typedef SystemAiStatusResponse = pb.SystemAiStatusResponse;
typedef AskAiResponse = pb.AskAiResponse;
typedef ListSystemAiModelsResponse = pb.ListSystemAiModelsResponse;
typedef SystemAiModel = pb.SystemAiModel;
typedef PullSystemAiModelResponse = pb.PullSystemAiModelResponse;
typedef ModuleInfoResponse = pb.ModuleInfoResponse;
typedef FlowSummary = pb.FlowSummary;
typedef StoreEntry = pb.StoreEntry;
@ -219,10 +222,55 @@ class HubClient {
));
}
/// Probe the configured provider with a tiny ping. Same
/// error-kind taxonomy as [askAi].
Future<AskAiResponse> testSystemAi() {
return _admin.testSystemAi(Empty());
/// Probe a (possibly draft) System-AI configuration. Pass the
/// form values from the editor so "Test connection" works
/// without a save first. Empty fields fall back to the live
/// in-memory config.
Future<AskAiResponse> testSystemAi({
String provider = '',
String endpoint = '',
String model = '',
String apiKeyEnv = '',
String privacyMode = '',
}) {
return _admin.testSystemAi(pb.TestSystemAiRequest(
provider: provider,
endpoint: endpoint,
model: model,
apiKeyEnv: apiKeyEnv,
privacyMode: privacyMode,
));
}
/// List the models the configured provider exposes via
/// `GET /v1/models`. Same draft-vs-live semantics as
/// [testSystemAi]. Errors come back inside
/// [ListSystemAiModelsResponse.errorKind].
Future<ListSystemAiModelsResponse> listSystemAiModels({
String provider = '',
String endpoint = '',
String apiKeyEnv = '',
}) {
return _admin.listSystemAiModels(pb.TestSystemAiRequest(
provider: provider,
endpoint: endpoint,
apiKeyEnv: apiKeyEnv,
));
}
/// Pull (download + install) an Ollama model via /api/pull.
/// Synchronous; takes minutes for large models. Errors come
/// back inside [PullSystemAiModelResponse.errorKind].
Future<PullSystemAiModelResponse> pullSystemAiModel({
required String endpoint,
required String model,
String apiKeyEnv = '',
}) {
return _admin.pullSystemAiModel(pb.PullSystemAiModelRequest(
endpoint: endpoint,
model: model,
apiKeyEnv: apiKeyEnv,
));
}
/// Search the hub's bundled store index. All filters are