using AIStudio.Chat;
using AIStudio.Provider;
namespace AIStudio.Tools.ToolCallingSystem;
///
/// The request a tool is being prepared for.
///
///
/// What a tool may look at when it tailors its function to a request, see
/// IToolImplementation.ResolveFunctionAsync. Semantic Search, for instance, reads the data sources
/// of the chat and describes exactly those which this provider may search.
/// A record, so whoever adds to a request copies it with all it holds, see
/// ToolRegistry.GetRunnableToolsAsync, and a property added later is not lost on the way.
///
public sealed record ToolResolutionContext
{
///
/// The provider the request goes to, with the expert settings of the user.
///
public required AIStudio.Settings.Provider Provider { get; init; }
///
/// The part of the app the request comes from.
///
public required Components Component { get; init; }
///
/// How much the provider is trusted.
///
public required ConfidenceLevel ProviderConfidence { get; init; }
///
/// The chat the request continues.
///
public required ChatThread ChatThread { get; init; }
///
/// The tools which passed every check for this request and are asked what they offer, or null
/// when whoever asks does not know them.
///
///
/// Lets a tool word its instructions after the other tools of the request: a rule about a tool
/// the model does not get would only confuse it. Filled by ToolRegistry.GetRunnableToolsAsync.
/// A candidate may still offer nothing in the end, see IToolImplementation.ResolveFunctionAsync.
///
public IReadOnlySet? CandidateToolIds { get; init; }
///
/// Whether this request may offer the given tool as well.
///
///
/// Without the candidates, every tool may be there, so a rule about it is kept rather than lost.
///
/// The ID of the tool.
/// True when the tool is a candidate of this request, or when the candidates are unknown.
public bool MayOffer(string toolId) => this.CandidateToolIds?.Contains(toolId) ?? true;
}