|
53 | 53 | using StabilityMatrix.Avalonia.Views; |
54 | 54 | using StabilityMatrix.Core.Api; |
55 | 55 | using StabilityMatrix.Core.Api.LykosAuthApi; |
| 56 | +using StabilityMatrix.Core.Api.PromptGenApi; |
56 | 57 | using StabilityMatrix.Core.Attributes; |
57 | 58 | using StabilityMatrix.Core.Converters.Json; |
58 | 59 | using StabilityMatrix.Core.Database; |
@@ -133,6 +134,14 @@ public sealed class App : Application |
133 | 134 | #else |
134 | 135 | public const string LykosAccountApiBaseUrl = "https://account.lykos.ai/"; |
135 | 136 | #endif |
| 137 | +#if DEBUG |
| 138 | + // ReSharper disable twice LocalizableElement |
| 139 | + // ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract |
| 140 | + public static string PromptGenApiBaseUrl => |
| 141 | + Config?["PromptGenApiBaseUrl"] ?? "https://promptgen.lykos.ai/api"; |
| 142 | +#else |
| 143 | + public const string PromptGenApiBaseUrl = "https://promptgen.lykos.ai/api"; |
| 144 | +#endif |
136 | 145 |
|
137 | 146 | // ReSharper disable once MemberCanBePrivate.Global |
138 | 147 | public IClassicDesktopStyleApplicationLifetime? DesktopLifetime => |
@@ -369,7 +378,7 @@ internal static void ConfigurePageViewModels(IServiceCollection services) |
369 | 378 | new MainWindowViewModel( |
370 | 379 | provider.GetRequiredService<ISettingsManager>(), |
371 | 380 | provider.GetRequiredService<IDiscordRichPresenceService>(), |
372 | | - provider.GetRequiredService<ServiceManager<ViewModelBase>>(), |
| 381 | + provider.GetRequiredService<IServiceManager<ViewModelBase>>(), |
373 | 382 | provider.GetRequiredService<ITrackedDownloadService>(), |
374 | 383 | provider.GetRequiredService<IModelIndexService>(), |
375 | 384 | provider.GetRequiredService<Lazy<IModelDownloadLinkHandler>>(), |
@@ -651,6 +660,21 @@ internal static IServiceCollection ConfigureServices() |
651 | 660 | new TokenAuthHeaderHandler(serviceProvider.GetRequiredService<LykosAuthTokenProvider>()) |
652 | 661 | ); |
653 | 662 |
|
| 663 | + services |
| 664 | + .AddRefitClient<IPromptGenApi>(defaultRefitSettings) |
| 665 | + .ConfigureHttpClient(c => |
| 666 | + { |
| 667 | + c.BaseAddress = new Uri(PromptGenApiBaseUrl); |
| 668 | + c.Timeout = TimeSpan.FromHours(1); |
| 669 | + c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ""); |
| 670 | + }) |
| 671 | + .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false }) |
| 672 | + .AddPolicyHandler(retryPolicy) |
| 673 | + .AddHttpMessageHandler( |
| 674 | + serviceProvider => |
| 675 | + new TokenAuthHeaderHandler(serviceProvider.GetRequiredService<LykosAuthTokenProvider>()) |
| 676 | + ); |
| 677 | + |
654 | 678 | services |
655 | 679 | .AddRefitClient<ILykosAnalyticsApi>(defaultRefitSettings) |
656 | 680 | .ConfigureHttpClient(c => |
|
0 commit comments