using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using xAiApi.Interfaces; using xCommons.Configurations; using xCommons.Providers; namespace xAiApi.Controllers { [Authorize] [Route("[controller]")] public abstract class XAiEmbeddingServiceControllerBase : XAiServiceControllerBase, IXAiEmbeddingServiceControllerBase where TAiService : IXAiEmbeddingServiceBase { private readonly TAiService aiService; protected XAiEmbeddingServiceControllerBase( ILogger logger, TAiService aiService, XAppConfiguration appConfiguration, XValidationProvider validationProvider ) : base( logger, aiService, appConfiguration, validationProvider ) { this.aiService = aiService; } /// /// Request For Embedding Specified String ... /// /// /// /// [AllowAnonymous] [HttpGet("Embeding")] public async Task> Embeding( [FromQuery] string content, CancellationToken cancellationToken = default ) { // try { // // Validate ... ValidationProvider.NotEmpty(content); // var result = await aiService.Embeding( content: content, cancellationToken: cancellationToken ); // return Ok(result); } catch (Exception ex) { // var result = GetExceptionActionResult(ex); return result; } } /// /// Request For Embedding Specified Batch ... /// /// /// /// [AllowAnonymous] [HttpGet("Embedings")] public async Task>> Embedings( [FromQuery] string[] batch, CancellationToken cancellationToken = default ) { // try { // // Validate ... ValidationProvider.NotZeroChilds(batch); // var result = await aiService.Embedings( batch: batch, cancellationToken: cancellationToken ); // return Ok(result); } catch (Exception ex) { // var result = GetExceptionActionResult(ex); return result; } } } }