| 
									
										
										
										
											2024-05-04 08:58:18 +00:00
										 |  |  | using AIStudio.Chat; | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  | using AIStudio.Settings; | 
					
						
							|  |  |  | using Microsoft.JSInterop; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-04 08:58:18 +00:00
										 |  |  | using MudBlazor; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  | namespace AIStudio.Provider; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-04 08:55:00 +00:00
										 |  |  | /// <summary> | 
					
						
							|  |  |  | /// A common interface for all providers. | 
					
						
							|  |  |  | /// </summary> | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  | public interface IProvider | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-05-04 08:55:00 +00:00
										 |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// The provider's ID. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  |     public string Id { get; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-04 08:55:00 +00:00
										 |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// The provider's instance name. Useful for multiple instances of the same provider, | 
					
						
							|  |  |  |     /// e.g., to distinguish between different OpenAI API keys. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  |     public string InstanceName { get; set; } | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2024-05-04 08:58:18 +00:00
										 |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// Starts a chat completion stream. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     /// <param name="jsRuntime">The JS runtime to access the Rust code.</param> | 
					
						
							|  |  |  |     /// <param name="settings">The settings manager to access the API key.</param> | 
					
						
							|  |  |  |     /// <param name="chatModel">The model to use for chat completion.</param> | 
					
						
							|  |  |  |     /// <param name="chatThread">The chat thread to continue.</param> | 
					
						
							|  |  |  |     /// <param name="token">The cancellation token.</param> | 
					
						
							|  |  |  |     /// <returns>The chat completion stream.</returns> | 
					
						
							|  |  |  |     public IAsyncEnumerable<string> StreamChatCompletion(IJSRuntime jsRuntime, SettingsManager settings, Model chatModel, ChatThread chatThread, CancellationToken token = default); | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// Starts an image completion stream. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     /// <param name="jsRuntime">The JS runtime to access the Rust code.</param> | 
					
						
							|  |  |  |     /// <param name="settings">The settings manager to access the API key.</param> | 
					
						
							|  |  |  |     /// <param name="imageModel">The model to use for image completion.</param> | 
					
						
							|  |  |  |     /// <param name="promptPositive">The positive prompt.</param> | 
					
						
							|  |  |  |     /// <param name="promptNegative">The negative prompt.</param> | 
					
						
							|  |  |  |     /// <param name="referenceImageURL">The reference image URL.</param> | 
					
						
							|  |  |  |     /// <param name="token">The cancellation token.</param> | 
					
						
							|  |  |  |     /// <returns>The image completion stream.</returns> | 
					
						
							|  |  |  |     public IAsyncEnumerable<ImageURL> StreamImageCompletion(IJSRuntime jsRuntime, SettingsManager settings, Model imageModel, string promptPositive, string promptNegative = FilterOperator.String.Empty, ImageURL referenceImageURL = default, CancellationToken token = default); | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2024-05-04 08:58:18 +00:00
										 |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// Load all possible text models that can be used with this provider. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     /// <param name="jsRuntime">The JS runtime to access the Rust code.</param> | 
					
						
							|  |  |  |     /// <param name="settings">The settings manager to access the API key.</param> | 
					
						
							|  |  |  |     /// <param name="token">The cancellation token.</param> | 
					
						
							|  |  |  |     /// <returns>The list of text models.</returns> | 
					
						
							|  |  |  |     public Task<IList<Model>> GetTextModels(IJSRuntime jsRuntime, SettingsManager settings, CancellationToken token = default); | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// Load all possible image models that can be used with this provider. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     /// <param name="jsRuntime">The JS runtime to access the Rust code.</param> | 
					
						
							|  |  |  |     /// <param name="settings">The settings manager to access the API key.</param> | 
					
						
							|  |  |  |     /// <param name="token">The cancellation token.</param> | 
					
						
							|  |  |  |     /// <returns>The list of image models.</returns> | 
					
						
							|  |  |  |     public Task<IList<Model>> GetImageModels(IJSRuntime jsRuntime, SettingsManager settings, CancellationToken token = default); | 
					
						
							| 
									
										
										
										
											2024-04-20 15:06:50 +00:00
										 |  |  | } |