69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using xAiService.Controllers;
|
|
using xAiService.Interfaces;
|
|
using xCommons.Attributes;
|
|
using xCommons.Configurations;
|
|
using xCommons.Providers;
|
|
using xIdentityHelper;
|
|
using xIdentityService.Interfaces;
|
|
|
|
namespace xApi.Controllers.V1
|
|
{
|
|
[ApiController]
|
|
[ApiVersion("1.0")]
|
|
[RequireXPowered(true)]
|
|
[Route("api/v{version:apiVersion}/[controller]")]
|
|
public class AiController : XAiServiceControllerBase, IXAiServiceControllerBase
|
|
{
|
|
//
|
|
#region Constructor ...
|
|
public AiController(
|
|
ILogger<AiController> logger,
|
|
IXAiService aiService,
|
|
XAppConfiguration appConfiguration,
|
|
IXIdentityProvider identityProvider,
|
|
XValidationProvider validationProvider
|
|
) : base(
|
|
logger,
|
|
aiService,
|
|
appConfiguration,
|
|
identityProvider,
|
|
validationProvider
|
|
)
|
|
{ }
|
|
#endregion
|
|
|
|
//
|
|
#region Text Actions ...
|
|
[HttpGet("Ask")]
|
|
[Authorize(Policy = XPolicies.EnabledUser)]
|
|
public override async Task<ActionResult<string>> Ask(
|
|
[FromQuery] string prompt,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await base.Ask(
|
|
prompt: prompt,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
[HttpGet("AskStream")]
|
|
[Authorize(Policy = XPolicies.EnabledUser)]
|
|
public override async Task<ActionResult> AskStream(
|
|
[FromQuery] string prompt,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
return await base.AskStream(
|
|
prompt: prompt,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
#endregion
|
|
}
|
|
} |