29 lines
1.3 KiB
C#
29 lines
1.3 KiB
C#
using System.Text.Json;
|
|
|
|
namespace NucleicBroker;
|
|
|
|
/// <summary>
|
|
/// The `ai.generate` seam (docs/WINDOWS_PORT.md §9.2): Phi Silica via Windows AI Foundry is
|
|
/// WinRT-only, so hostd routes on-device-AI requests through this broker rather than a
|
|
/// second helper process. Capability-probed: on non-Copilot+ hardware (or off-Windows) the
|
|
/// provider is unavailable and hostd's Intelligence seam falls back to its heuristics —
|
|
/// identical UX to a Mac without Apple Intelligence.
|
|
/// </summary>
|
|
public interface IAiProvider
|
|
{
|
|
bool IsAvailable { get; }
|
|
/// <summary>Generate text for `prompt`; when `schema` is present the result must be JSON
|
|
/// conforming to it (guided generation). Throws WslcError(AiUnavailable) when absent.</summary>
|
|
Task<string> GenerateAsync(string prompt, JsonElement? schema, CancellationToken ct);
|
|
}
|
|
|
|
/// <summary>Default provider: no on-device model. The real Foundry-backed provider lands
|
|
/// with work item 16 behind the same interface.</summary>
|
|
public sealed class UnavailableAiProvider : IAiProvider
|
|
{
|
|
public bool IsAvailable => false;
|
|
|
|
public Task<string> GenerateAsync(string prompt, JsonElement? schema, CancellationToken ct) =>
|
|
throw new WslcError(WslcError.AiUnavailable, "no on-device AI provider on this machine");
|
|
}
|