last ...
This commit is contained in:
+44
-2
@@ -3,13 +3,14 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.AI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xAiService.Base;
|
||||
using xAiService.Configurations;
|
||||
using xAiService.Constants;
|
||||
using xAiService.Interfaces;
|
||||
using xCommons.Providers;
|
||||
using xHttpService.Constants;
|
||||
using xIdentityModels.Models;
|
||||
using xIdentityService.Interfaces;
|
||||
using xIdentityService.Providers;
|
||||
|
||||
namespace xAiService.Services
|
||||
{
|
||||
@@ -48,6 +49,7 @@ namespace xAiService.Services
|
||||
/// <returns></returns>
|
||||
public Task<ChatResponse> GetResponseAsync(
|
||||
string prompt,
|
||||
XUserClaimsInfoDto userInfo,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
@@ -62,6 +64,7 @@ namespace xAiService.Services
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetTextResponseAsync(
|
||||
string prompt,
|
||||
XUserClaimsInfoDto userInfo,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
@@ -70,7 +73,46 @@ namespace xAiService.Services
|
||||
ValidationProvider.NotEmpty(prompt);
|
||||
|
||||
//
|
||||
var client = GetRestClient();
|
||||
var client = GetRestClient(userInfo);
|
||||
var request = GetRestRequet(
|
||||
endpoint: XAiApiEndpoint.Ask,
|
||||
addXPoweredValue: true,
|
||||
queryStrings: new Dictionary<string, string>
|
||||
{
|
||||
{ XAiApiQueryParams.Prompt, prompt }
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<string>(
|
||||
client,
|
||||
request,
|
||||
XHttpMethod.GET,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate Text Response Stream ...
|
||||
/// </summary>
|
||||
/// <param name="prompt"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task GetTextReponseStreamAsync(
|
||||
string prompt,
|
||||
XUserClaimsInfoDto userInfo,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
ValidationProvider.NotEmpty(prompt);
|
||||
|
||||
//
|
||||
var client = GetRestClient(userInfo);
|
||||
var request = GetRestRequet(
|
||||
endpoint: XAiApiEndpoint.Ask,
|
||||
addXPoweredValue: true,
|
||||
|
||||
Reference in New Issue
Block a user