| | | 1 | | namespace Intentum.AI.SystemOne; |
| | | 2 | | |
| | | 3 | | /// <summary>Presets for known System One compatible engines (Jev wire protocol).</summary> |
| | | 4 | | public static class SystemOneEngines |
| | | 5 | | { |
| | | 6 | | /// <summary>Known engine names accepted by <see cref="FromName"/>.</summary> |
| | 2 | 7 | | public static IReadOnlyList<string> Names { get; } = |
| | 1 | 8 | | ["demo", "jev", "kev", "tinyjev", "laya", "opendecision", "decision10", "openjev", "nanojev", "openjevpro", "foq |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// In-process demo engine hosted by the consuming app itself (POST /v1/systemone). |
| | | 12 | | /// No API key, no model download; deterministic keyword-based decisions. |
| | | 13 | | /// <paramref name="baseUrl"/> is resolved at request time (app origin) by the host. |
| | | 14 | | /// The host must assign a <c>BaseUrl</c> before constructing a client or model; <see cref="SystemOneOptions.Validat |
| | | 15 | | /// </summary> |
| | | 16 | | public static SystemOneOptions Demo(string baseUrl = "") => |
| | 2 | 17 | | new() { BaseUrl = baseUrl, Engine = "demo", Model = "demo-latest" }; |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Jev (TypeSafe AI): hosted System One model at <c>https://api.typesafe.ai</c>. |
| | | 21 | | /// Requires an API key from <c>console.typesafe.ai/keys</c>; picked up from |
| | | 22 | | /// <c>TYPESAFE_API_KEY</c> unless overridden via <c>ApiKey</c>. |
| | | 23 | | /// </summary> |
| | | 24 | | public static SystemOneOptions Jev(string baseUrl = "https://api.typesafe.ai") => |
| | 2 | 25 | | new() |
| | 2 | 26 | | { |
| | 2 | 27 | | BaseUrl = baseUrl, |
| | 2 | 28 | | Engine = "jev", |
| | 2 | 29 | | Model = "jev-latest", |
| | 2 | 30 | | ApiKey = Environment.GetEnvironmentVariable("TYPESAFE_API_KEY"), |
| | 2 | 31 | | }; |
| | | 32 | | |
| | | 33 | | /// <summary>Kev (jaredpalmer/kev): local server, default port 8009.</summary> |
| | | 34 | | public static SystemOneOptions Kev(string baseUrl = "http://127.0.0.1:8009") => |
| | 1 | 35 | | new() { BaseUrl = baseUrl, Engine = "kev", Model = "kev-latest" }; |
| | | 36 | | |
| | | 37 | | /// <summary>TinyJev (ankit-aglawe/tinyjev): <c>tinyjev serve</c>, default port 8077.</summary> |
| | | 38 | | public static SystemOneOptions TinyJev(string baseUrl = "http://127.0.0.1:8077") => |
| | 1 | 39 | | new() { BaseUrl = baseUrl, Engine = "tinyjev" }; |
| | | 40 | | |
| | | 41 | | /// <summary>Laya (NandhaKishorM/laya): <c>laya-serve</c>, default port 8000.</summary> |
| | | 42 | | public static SystemOneOptions Laya(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 43 | | new() { BaseUrl = baseUrl, Engine = "laya" }; |
| | | 44 | | |
| | | 45 | | /// <summary>OpenDecision: local System One compatible server.</summary> |
| | | 46 | | public static SystemOneOptions OpenDecision(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 47 | | new() { BaseUrl = baseUrl, Engine = "opendecision" }; |
| | | 48 | | |
| | | 49 | | /// <summary>Decision 1.0: System One compatible server.</summary> |
| | | 50 | | public static SystemOneOptions Decision10(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 51 | | new() { BaseUrl = baseUrl, Engine = "decision10" }; |
| | | 52 | | |
| | | 53 | | /// <summary>Open-Jev: HTTP server speaking the TypeSafe System One API.</summary> |
| | | 54 | | public static SystemOneOptions OpenJev(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 55 | | new() { BaseUrl = baseUrl, Engine = "openjev" }; |
| | | 56 | | |
| | | 57 | | /// <summary>NanoJev: local System One compatible server.</summary> |
| | | 58 | | public static SystemOneOptions NanoJev(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 59 | | new() { BaseUrl = baseUrl, Engine = "nanojev" }; |
| | | 60 | | |
| | | 61 | | /// <summary>OpenJevPro / openjev-sglang: System One API over SGLang.</summary> |
| | | 62 | | public static SystemOneOptions OpenJevPro(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 63 | | new() { BaseUrl = baseUrl, Engine = "openjevpro" }; |
| | | 64 | | |
| | | 65 | | /// <summary>Foq: System One compatible server.</summary> |
| | | 66 | | public static SystemOneOptions Foq(string baseUrl = "http://127.0.0.1:8000") => |
| | 1 | 67 | | new() { BaseUrl = baseUrl, Engine = "foq" }; |
| | | 68 | | |
| | | 69 | | /// <summary>Resolves a preset by engine name (case-insensitive).</summary> |
| | | 70 | | /// <param name="name">Engine name; see <see cref="Names"/>.</param> |
| | | 71 | | /// <param name="baseUrl">Optional base URL override.</param> |
| | | 72 | | /// <exception cref="ArgumentException">Thrown when the engine name is unknown.</exception> |
| | | 73 | | public static SystemOneOptions FromName(string name, string? baseUrl = null) |
| | 13 | 74 | | { |
| | 13 | 75 | | ArgumentException.ThrowIfNullOrWhiteSpace(name); |
| | | 76 | | |
| | 13 | 77 | | var options = name.Trim().ToLowerInvariant() switch |
| | 13 | 78 | | { |
| | 2 | 79 | | "demo" => Demo(), |
| | 1 | 80 | | "jev" => Jev(), |
| | 1 | 81 | | "kev" => Kev(), |
| | 1 | 82 | | "tinyjev" => TinyJev(), |
| | 1 | 83 | | "laya" => Laya(), |
| | 1 | 84 | | "opendecision" => OpenDecision(), |
| | 1 | 85 | | "decision10" => Decision10(), |
| | 1 | 86 | | "openjev" => OpenJev(), |
| | 1 | 87 | | "nanojev" => NanoJev(), |
| | 1 | 88 | | "openjevpro" => OpenJevPro(), |
| | 1 | 89 | | "foq" => Foq(), |
| | 1 | 90 | | _ => throw new ArgumentException( |
| | 1 | 91 | | $"Unknown System One engine '{name}'. Known engines: {string.Join(", ", Names)}.", |
| | 1 | 92 | | nameof(name)), |
| | 13 | 93 | | }; |
| | | 94 | | |
| | 12 | 95 | | return baseUrl is null ? options : options with { BaseUrl = baseUrl }; |
| | 12 | 96 | | } |
| | | 97 | | } |