using AIStudio.Provider;
namespace AIStudio.AIOperations;
///
/// A task which AI Studio hands to a model on its own: one request in, one result out, without a loop.
///
///
///
/// An operation is registered as a singleton and keeps no state between calls, so several callers may run
/// it at the same time, e.g., two chats with RAG. Everything a call needs travels with it: the request, and
/// in the AIOperationContext the provider which the caller chose for it.
///
///
/// Each operation also declares a static method GetProviderSettings(SettingsManager), which reads the
/// provider settings of the operation fresh on every call. It is static, so that a service can learn which
/// provider would run without an instance of the operation. AIOperationProviderResolver chooses the
/// provider from these settings; see the AGENTS.md of this folder.
///
///
/// What the operation works on.
/// What the operation returns.
public interface IAIOperation
{
///
/// The name of the operation in the log, in English.
///
public string Id { get; }
///
/// The component the operation runs as.
///
///
/// Its requests name it, e.g., in the User-Agent for self-hosted servers. Without it, an operation
/// working for an assistant would be counted as chat.
///
public Tools.Components Component { get; }
///
/// The confidence level which the content of the request requires of a provider.
///
///
/// It comes from the request alone, e.g., from the data sources it carries or from the confidence a
/// chat requires. The minimum confidence of the operation itself is a setting and not part of it.
///
/// The request to run.
/// The confidence level the content requires, NONE when it requires nothing.
public ConfidenceLevel GetRequiredConfidence(TRequest request);
///
/// Runs the operation for one request.
///
/// The request to run.
/// What the call runs with, the provider above all.
/// The cancellation token.
/// The result of the operation.
public Task RunAsync(TRequest request, AIOperationContext context, CancellationToken token = default);
}