using System; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using xAiService.Interfaces; using xCommons.Configurations; using xCommons.Providers; using xIdentityService.Controllers; using xIdentityService.Interfaces; namespace xAiService.Controllers { /// /// a Controller base Class which implement based Actions to Provides AI Service Access ... /// public abstract class XAiServiceControllerBase : XIBaseProviderController, IXAiServiceControllerBase { private readonly IXAiService aiService; protected XAiServiceControllerBase( ILogger logger, IXAiService aiService, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, XValidationProvider validationProvider ) : base( logger, appConfiguration, identityProvider, validationProvider ) { this.aiService = aiService; } // #region Text Actions ... [HttpGet("Ask")] public virtual async Task> Ask( [FromQuery] string prompt, CancellationToken cancellationToken = default ) { // // Do ... try { // var tokens = Ex(); var result = await aiService .GetTextResponseAsync( prompt: prompt, tokens: tokens, cancellationToken: cancellationToken ); // return Ok(result); } catch (Exception ex) { // var result = GetExceptionActionResult(ex); return result; } } [HttpGet("AskStream")] public async Task AskAIStream( [FromQuery] string prompt, CancellationToken cancellationToken = default ) { } #endregion } }