using System;
using xModels.Dtos;
using System.Threading;
using xAiModels.Models.Dtos;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace xAiModels.Interfaces
{
///
/// All Data Manipulation Requirements ...
///
public interface IXAiDataProvider
{
//
#region Getters ...
///
/// Retrieve Specified Project ...
///
///
///
///
///
///
Task GetProject(
Guid id,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Retrieve Specified Conversation ...
///
///
///
///
///
Task GetConversation(
Guid id,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
#endregion
//
#region Loaders ...
///
/// Load Projects List of Specified Owner ...
///
///
///
///
///
///
///
Task> LoadProjects(
string ownerId,
string connectionId = null,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Load List of Conversations for Specified Project ...
///
///
///
///
///
///
Task> LoadConversations(
Guid projectId,
bool fillMessages = false,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Load Messages of Specified Conversation ...
///
///
///
///
Task> LoadMessages(
Guid conversationId,
CancellationToken cancellationToken = default
);
#endregion
//
#region Enrichers ...
///
/// Enrich Specified Item ...
///
///
///
///
///
///
Task Enrich(
XAiProjectDto source,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
///
Task Enrich(
XAiConversationDto source,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiMessageDto source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
#endregion
//
#region Defaults ...
///
/// Retrieve Default Project of Specified Owner ...
/// Create it if not Handled ...
///
///
///
///
///
Task GetDefaultProject(
string ownerId,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Retrieve Default Conversation of Specified Owner ...
/// Create it if not Handled ...
///
///
///
///
///
///
Task GetDefaultConversation(
string ownerId,
Guid? projectId,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Creator/Adders ...
///
/// Create Project ...
///
///
///
///
///
///
Task CreateProject(
string ownerId,
XAiProjectDto item = null,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Create Conversation ...
///
///
///
///
///
///
///
Task CreateConversation(
string ownerId,
Guid projectId,
XAiConversationDto item = null,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Add Message ...
///
///
///
///
///
///
Task AddMessage(
Guid conversationId,
XAiMessageDto item,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Query ...
///
/// 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 Vectors ...
///
/// Insert or Update a Single Vector (Matched by Identifier) ...
///
///
///
///
///
///
///
///
Task UpsertVectorAsync(
string identifier,
string text,
ReadOnlyMemory embedding,
Dictionary metadata = null,
string type = null,
CancellationToken cancellationToken = default
);
///
/// Insert or Update a Batch of Vectors (Matched by Identifier) ...
///
///
///
/// Count of Stored Vectors
Task UpsertVectorsAsync(
IEnumerable items,
CancellationToken cancellationToken = default
);
///
/// Search Vectors by Cosine Similarity (Top K) ...
///
///
///
///
/// Optional: Restrict Search to Vectors whose Identifier Starts with this Prefix
/// Optional: Restrict Search to Vectors of Specified Type
///
///
Task> SearchVectorsAsync(
ReadOnlyMemory queryEmbedding,
int topK = 5,
float minScore = 0f,
string identifierPrefix = null,
string type = null,
CancellationToken cancellationToken = default
);
///
/// Load Vectors whose Identifier Starts with Specified Prefix ...
///
///
///
/// Optional: Restrict to Vectors of Specified Type
///
///
Task> LoadVectorsAsync(
string identifierPrefix,
bool includeEmbedding = false,
string type = null,
CancellationToken cancellationToken = default
);
///
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
///
///
/// Optional: Restrict to Vectors of Specified Type
///
/// Count of Removed Vectors
Task RemoveVectorsAsync(
string identifierPrefix,
string type = null,
CancellationToken cancellationToken = default
);
#endregion
}
}