This commit is contained in:
2026-07-26 21:19:46 +03:30
parent cece849cdf
commit 4245ba726f
2 changed files with 0 additions and 101 deletions
-100
View File
@@ -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
View File
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<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="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" disableTLSCertificateValidation="true" />
</packageSources>