using System;
using xModels.Dtos;
using System.Threading;
using xAiModels.Models;
using xAiModels.Models.Dtos;
using System.Threading.Tasks;
using xIdentityModels.Models;
using Microsoft.Extensions.AI;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
namespace xAiApi.Interfaces
{
///
/// Describe a Base Service Actions of any Ai Based Services ...
///
public interface IXAiServiceBase : IDisposable
{
///
/// Chat Options ...
///
ChatOptions Options { get; }
///
/// Descriptor of Models which used in Service ...
///
XAiModelDescriptor Descriptor { get; }
//
#region Actions ...
///
/// Base Method for Communicate with LLM ...
///
///
///
///
///
Task AskTextAsync(
string prompt,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Base Method for Communicate with LLM ...
///
///
///
///
///
IAsyncEnumerable AskTextAsEnumerable(
string prompt,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Ask a Question By Providing Vector Search Result ...
///
///
///
///
///
///
Task AskTextByContextAsync(
string prompt,
IList context = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Ask a Question By By Providing Vector Search Result and Stream Response ...
///
///
///
///
///
///
IAsyncEnumerable AskTextByContextAsEnumerable(
string prompt,
IList context = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Ask a Question By Rag Retrive From Knowledge ...
///
///
///
///
///
///
///
///
Task AskTextFromKnowledgeAsync(
string prompt,
string type = null,
int? topK = null,
float? minScore = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Ask a Question By Rag Retrive From Knowledge and Stream Response ...
///
///
///
///
///
///
///
///
IAsyncEnumerable AskTextFromKnowledgeAsEnumerable(
string prompt,
string type = null,
int? topK = null,
float? minScore = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Ask a Question as Prompt and Retrieve Response ...
///
///
///
///
///
///
///
///
///
///
///
///
///
///
Task AskAsync(
string prompt,
string type = null,
int? topK = null,
float? minScore = null,
Guid? projectId = null,
Guid? conversationId = null,
string connectionId = null,
bool extractFileContents = false,
bool addFilesToKnowledge = true,
IFormFileCollection files = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Ask a Question as Prompt and Retrieve Response as Async Enumerable ...
///
///
///
///
///
///
///
///
///
///
///
///
///
///
IAsyncEnumerable AskAsEnumerable(
string prompt,
string type = null,
int? topK = null,
float? minScore = null,
Guid? projectId = null,
Guid? conversationId = null,
string connectionId = null,
bool extractFileContents = false,
bool addFilesToKnowledge = true,
IFormFileCollection files = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Loaders ...
///
/// Load AI Projects ...
///
///
///
///
///
///
Task> LoadProjects(
string ownerId,
string connectionId = null,
bool includeDefaults = false,
CancellationToken cancellationToken = default
);
///
/// Load Conversations of Specified AI Project ...
///
///
///
///
///
///
Task> LoadConversations(
Guid? projectId,
string ownerId = null,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Load Messages of Specified Conversation ...
///
///
///
///
///
///
Task> LoadMessages(
Guid? conversationId,
string ownerId = null,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Queries ...
///
/// Query Projects ...
///
///
///
///
///
Task> QueryProjects(
string ownerId,
XQuery query,
CancellationToken cancellationToken = default
);
///
/// Query Conversations ...
///
///
///
///
///
///
Task> QueryConversations(
string ownerId,
Guid projectId,
XQuery query,
CancellationToken cancellationToken = default
);
///
/// Query Messages ...
///
///
///
///
///
///
Task> QueryMessages(
string ownerId,
Guid conversationId,
XQuery query,
CancellationToken cancellationToken = default
);
#endregion
//
#region Creators ...
///
/// Create an AI Project ...
///
///
///
///
///
///
Task CreateProject(
string ownerId,
XAiProjectDto item,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Create an AI Conversation ...
///
///
///
///
///
///
///
Task CreateConversation(
string ownerId,
Guid projectId,
XAiConversationDto item,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Content Extraction ...
///
/// Try to Extract Files Content ...
///
///
///
///
///
Task ExtractContent(
IFormFileCollection files,
string[] extractors = null,
CancellationToken cancellationToken = default
);
#endregion
}
}