last ...
This commit is contained in:
@@ -1,100 +0,0 @@
|
|||||||
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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// a Controller base Class which implement based Actions to Provides AI Service Access ...
|
|
||||||
/// </summary>
|
|
||||||
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<ActionResult<string>> Ask(
|
|
||||||
[FromQuery] string prompt,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var result = await aiService
|
|
||||||
.GetTextResponseAsync(
|
|
||||||
prompt: prompt,
|
|
||||||
userInfo: userInfo,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("AskStream")]
|
|
||||||
public virtual async Task<ActionResult> AskStream(
|
|
||||||
[FromQuery] string prompt,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var userInfo = await GetUserInfo();
|
|
||||||
var result = await aiService
|
|
||||||
.GetTextReponseStreamAsync(
|
|
||||||
prompt: prompt,
|
|
||||||
userInfo: userInfo,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var result = GetExceptionActionResult(ex);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packageSources>
|
<packageSources>
|
||||||
<!-- <add key="megan" value="https://hub.megan.ir/nuget/index.json" /> -->
|
|
||||||
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" disableTLSCertificateValidation="true" />
|
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" disableTLSCertificateValidation="true" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
|
|||||||
Reference in New Issue
Block a user