last ...
This commit is contained in:
@@ -144,3 +144,113 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: Remove ...
|
||||
|
||||
//
|
||||
// Reading Messages ...
|
||||
// var messages = await dataProvider.LoadMessages(
|
||||
// conversationId: conversationId,
|
||||
// cancellationToken: cancellationToken
|
||||
// );
|
||||
|
||||
//
|
||||
// TODO: Parse Files ...
|
||||
// for Attached them into Prompt Message ...
|
||||
|
||||
// //
|
||||
// // Handle Memory ...
|
||||
// IList<ChatMessage> history = await PrepareMemory(
|
||||
// project: project,
|
||||
// messages: messages,
|
||||
// cancellationToken: cancellationToken
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Prepare and Add Prompt Message ...
|
||||
// var promptMessage = new XAiMessageDto
|
||||
// {
|
||||
// Content = prompt,
|
||||
// OwnerId = ownerId,
|
||||
// Role = XAiChatRole.User,
|
||||
// CreatedOn = DateTime.UtcNow,
|
||||
// ConversationId = conversationId,
|
||||
// };
|
||||
// promptMessage = await dataProvider.AddMessage(
|
||||
// item: promptMessage,
|
||||
// connectionId: connectionId,
|
||||
// conversationId: conversationId,
|
||||
// cancellationToken: cancellationToken
|
||||
// );
|
||||
// promptMessage = await dataProvider.Enrich(
|
||||
// source: promptMessage,
|
||||
// cancellationToken: cancellationToken
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Attach Uploaded Files ...
|
||||
// var promptChatMessage = promptMessage
|
||||
// .ToChatMessages();
|
||||
// history.Add(promptChatMessage);
|
||||
|
||||
// //
|
||||
// // Ask Questions From LLM ...
|
||||
// using var client = Descriptor.GetClient();
|
||||
// var enumerable = client.GetStreamingResponseAsync(
|
||||
// options: null,
|
||||
// messages: history
|
||||
// );
|
||||
|
||||
// //
|
||||
// long sequence = 1;
|
||||
// var answer = string.Empty;
|
||||
// await foreach (var res in enumerable)
|
||||
// {
|
||||
// //
|
||||
// // Cancellation Token ...
|
||||
// if (cancellationToken.IsCancellationRequested)
|
||||
// {
|
||||
// yield break;
|
||||
// }
|
||||
|
||||
// //
|
||||
// var resp = new XAiResonseMessage
|
||||
// {
|
||||
// OwnerId = ownerId,
|
||||
// Content = res.Text,
|
||||
// Sequence = sequence,
|
||||
// Role = XAiChatRole.System,
|
||||
// RespondTo = promptMessage.Id,
|
||||
// RespondedOn = DateTime.UtcNow,
|
||||
// };
|
||||
|
||||
// //
|
||||
// sequence++;
|
||||
// answer += res.Text;
|
||||
|
||||
// //
|
||||
// yield return resp;
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Prepare Answer AI Message ...
|
||||
// var result = new XAiMessageDto
|
||||
// {
|
||||
// Content = answer,
|
||||
// OwnerId = ownerId,
|
||||
// Role = XAiChatRole.System,
|
||||
// CreatedOn = DateTime.UtcNow,
|
||||
// ConversationId = conversationId
|
||||
// };
|
||||
// result = await dataProvider.AddMessage(
|
||||
// item: result,
|
||||
// connectionId: connectionId,
|
||||
// conversationId: conversationId,
|
||||
// cancellationToken: cancellationToken
|
||||
// );
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using xAiApi.Interfaces;
|
||||
using xCommons.Providers;
|
||||
using xCommons.Configurations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityService.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace xAiApi.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("[controller]")]
|
||||
public class DefaultEmbeddingController : XAiEmbeddingServiceControllerBase<IXAiEmbeddingService>
|
||||
{
|
||||
public DefaultEmbeddingController(
|
||||
ILogger<DefaultEmbeddingController> logger,
|
||||
IXAiEmbeddingService embeddingService,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger: logger,
|
||||
appConfiguration: appConfiguration,
|
||||
identityProvider: identityProvider,
|
||||
embeddingService: embeddingService,
|
||||
validationProvider: validationProvider
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using xAiApi.Interfaces;
|
||||
using xCommons.Providers;
|
||||
using xCommons.Configurations;
|
||||
using xIdentityService.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace xAiApi.Controllers
|
||||
{
|
||||
public class DefaultThinkingAiController : XAiServiceControllerBase<IXDefaultThinkingAiService>
|
||||
{
|
||||
public DefaultThinkingAiController(
|
||||
ILogger<DefaultThinkingAiController> logger,
|
||||
IXDefaultThinkingAiService aiService,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
aiService,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using xAiApi.Interfaces;
|
||||
using xCommons.Providers;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Configurations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using xIdentityService.Interfaces;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xIdentityService.Controllers;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace xAiApi.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("[controller]")]
|
||||
public abstract class XAiEmbeddingServiceControllerBase<TEmbeddingService> : XBaseIdentityApiV1Controller, IXAiEmbeddingServiceControllerBase
|
||||
where TEmbeddingService : IXAiEmbeddingServiceBase
|
||||
{
|
||||
private readonly TEmbeddingService embeddingService;
|
||||
|
||||
protected XAiEmbeddingServiceControllerBase(
|
||||
ILogger logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
TEmbeddingService embeddingService
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{
|
||||
this.embeddingService = embeddingService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request For Embedding Specified String ...
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Embedding")]
|
||||
public async Task<ActionResult<float[]>> Embedding(
|
||||
[FromQuery] string content,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
ValidationProvider.NotEmpty(content);
|
||||
|
||||
//
|
||||
var result = await embeddingService.Embedding(
|
||||
content: content,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request For Embedding Specified Batch ...
|
||||
/// </summary>
|
||||
/// <param name="batch"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Embeddings")]
|
||||
public async Task<ActionResult<IReadOnlyList<float[]>>> Embeddings(
|
||||
[FromQuery] string[] batch,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
ValidationProvider.NotZeroChilds(batch);
|
||||
|
||||
//
|
||||
var result = await embeddingService.Embeddings(
|
||||
batch: batch,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+808
-796
File diff suppressed because it is too large
Load Diff
+156
-156
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -1,5 +1,5 @@
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\Constants\ConfigurationNodeNames.cs
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Constants\ConfigurationNodeNames.cs
|
||||
|
||||
namespace xAiService.Constants
|
||||
{
|
||||
@@ -9,7 +9,7 @@ namespace xAiService.Constants
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\Constants\XAiServiceConstants.cs
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Constants\XAiServiceConstants.cs
|
||||
|
||||
namespace xAiService.Constants
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace xAiService.Constants
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\DI\XDIHelperExtension.cs
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\DI\XDIHelperExtension.cs
|
||||
|
||||
namespace xAiService.DI
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace xAiService.DI
|
||||
{ }
|
||||
}
|
||||
|
||||
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xAiService\Extensions\XAiServiceExtensions.cs
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiService\Extensions\XAiServiceExtensions.cs
|
||||
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,9 @@
|
||||
}
|
||||
|
||||
{
|
||||
"accessToken": "EE124E2A77328DC1F31421B95A5AE85D9C3A63F4923F9B11AEDABCE1F6FD1FC0",
|
||||
"refreshToken": "EDD3C6C09C0DA61E18A04B6E77A20F45F161B63B6A544C52461A460BD400F443",
|
||||
"expiresAt": 1793347477
|
||||
"accessToken": "1015F99FAA5FBE58EFA750FCC7223C70EDA21CF7DDE3704FD5AECEB2AEE5BE7A",
|
||||
"refreshToken": "A5C760B20E409E048750036D541E942F01E8D7856F762B106A65C4872A443DB3",
|
||||
"expiresAt": 1793442806
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
+1
-1
Submodule Modules/xAiModels updated: 31a0d097c0...146137c908
+1
-1
Submodule xAiApi updated: c1173042d4...ce5db9e349
Reference in New Issue
Block a user