| 
									
										
										
										
											2024-04-19 19:25:44 +00:00
										 |  |  | using AIStudio.Settings; | 
					
						
							| 
									
										
										
										
											2024-07-24 13:17:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-19 19:25:44 +00:00
										 |  |  | using Microsoft.AspNetCore.Components; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-21 06:30:01 +00:00
										 |  |  | namespace AIStudio.Pages; | 
					
						
							| 
									
										
										
										
											2024-04-19 19:25:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-28 09:20:00 +00:00
										 |  |  | public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable | 
					
						
							| 
									
										
										
										
											2024-04-19 19:25:44 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  |     [Inject] | 
					
						
							| 
									
										
										
										
											2024-09-01 18:10:03 +00:00
										 |  |  |     private MessageBus MessageBus { get; init; } = null!; | 
					
						
							| 
									
										
										
										
											2024-07-24 13:17:45 +00:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2025-01-05 14:11:15 +00:00
										 |  |  |     private List<ConfigurationSelectData<string>> availableLLMProviders = new(); | 
					
						
							|  |  |  |     private List<ConfigurationSelectData<string>> availableEmbeddingProviders = new(); | 
					
						
							| 
									
										
										
										
											2025-01-13 18:51:26 +00:00
										 |  |  |     private List<ConfigurationSelectData<string>> availableDataSources = new(); | 
					
						
							| 
									
										
										
										
											2024-07-28 09:20:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     #region Overrides of ComponentBase | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected override async Task OnInitializedAsync() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Register this component with the message bus: | 
					
						
							|  |  |  |         this.MessageBus.RegisterComponent(this); | 
					
						
							|  |  |  |         this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]); | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         await base.OnInitializedAsync(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     #endregion | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     #region Implementation of IMessageBusReceiver | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-21 14:36:22 +00:00
										 |  |  |     public string ComponentName => nameof(Settings); | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2024-07-28 09:20:00 +00:00
										 |  |  |     public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch (triggeredEvent) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             case Event.CONFIGURATION_CHANGED: | 
					
						
							|  |  |  |                 this.StateHasChanged(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return Task.CompletedTask; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return Task.FromResult<TResult?>(default); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     #region Implementation of IDisposable | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void Dispose() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         this.MessageBus.Unregister(this); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-24 17:27:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-04 08:55:00 +00:00
										 |  |  |     #endregion | 
					
						
							| 
									
										
										
										
											2024-04-19 19:25:44 +00:00
										 |  |  | } |