last ...
This commit is contained in:
@@ -16,6 +16,7 @@ using xIdentityService.Interfaces;
|
||||
using xIdentityService.Controllers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using xIdentityHelper;
|
||||
|
||||
namespace xAiApi.Controllers
|
||||
{
|
||||
@@ -58,9 +59,10 @@ namespace xAiApi.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost("Ingest")]
|
||||
[Consumes("multipart/form-data")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<XAiKnowledgeIngestResult>> Ingest(
|
||||
[FromForm] IFormFileCollection files,
|
||||
[FromForm] XAiKnowledgeScope scope = XAiKnowledgeScope.Global,
|
||||
[FromForm] XAiKnowledgeScope? scope = XAiKnowledgeScope.Global,
|
||||
[FromForm] Guid? scopeId = null,
|
||||
[FromForm] string knowledgeType = null,
|
||||
[FromForm] bool replaceExisting = true,
|
||||
@@ -114,8 +116,9 @@ namespace xAiApi.Controllers
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Documents")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<IList<XAiKnowledgeDocumentInfo>>> Documents(
|
||||
[FromQuery] XAiKnowledgeScope scope = XAiKnowledgeScope.User,
|
||||
[FromQuery] XAiKnowledgeScope? scope = XAiKnowledgeScope.Global,
|
||||
[FromQuery] Guid? scopeId = null,
|
||||
[FromQuery] string knowledgeType = null,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -126,12 +129,13 @@ namespace xAiApi.Controllers
|
||||
{
|
||||
//
|
||||
var userInfo = await GetUserInfo();
|
||||
var scopeIdentifier = BuildScope(scope, scopeId, knowledgeType);
|
||||
|
||||
//
|
||||
var result = await ragService.LoadDocumentsAsync(
|
||||
userInfo: userInfo,
|
||||
cancellationToken: cancellationToken,
|
||||
scope: BuildScope(scope, scopeId, knowledgeType)
|
||||
scope: scopeIdentifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
@@ -154,9 +158,10 @@ namespace xAiApi.Controllers
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>Count of Removed Vectors</returns>
|
||||
[HttpDelete("Documents")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdmin)]
|
||||
public async Task<ActionResult<int>> DeleteDocument(
|
||||
[FromQuery] string fileName,
|
||||
[FromQuery] XAiKnowledgeScope scope = XAiKnowledgeScope.User,
|
||||
[FromQuery] XAiKnowledgeScope? scope = XAiKnowledgeScope.Global,
|
||||
[FromQuery] Guid? scopeId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -197,15 +202,21 @@ namespace xAiApi.Controllers
|
||||
/// Build Scope Descriptor from Request Params ...
|
||||
/// </summary>
|
||||
private XAiKnowledgeScopeDescriptor BuildScope(
|
||||
XAiKnowledgeScope scope,
|
||||
XAiKnowledgeScope? scope,
|
||||
Guid? scopeId,
|
||||
string knowledgeType
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!scope.HasValue)
|
||||
{
|
||||
scope = XAiKnowledgeScope.Global;
|
||||
}
|
||||
|
||||
//
|
||||
var result = new XAiKnowledgeScopeDescriptor
|
||||
{
|
||||
Scope = scope,
|
||||
Scope = scope.Value,
|
||||
ScopeId = scopeId,
|
||||
Type = knowledgeType,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user