using System.Collections.Frozen;
using AIStudio.Chat;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.ToolCallingSystem;
namespace AIStudio.Assistants.BeyondFactsLab;
///
/// The tools of the chats of the BeyondFacts Lab, and where the chats may send data.
///
///
/// The chat of a step knows the whole preparation, which may be unpublished. It therefore never searches the web: a
/// query could carry anything of the preparation to a search engine. It reads only web pages whose addresses were given
/// to it, in a message of the person, in their details or material, or in the research, see
/// ChatThread.IsWebAddressGivenToTheModel. The restriction of the chat enforces that for Read Web Page, whatever its
/// free address choice; the lab searches the web in agents of its own, see BflResearchRunner. The onboarding knows no
/// preparation and needs no tool.
///
public static class BflChatTools
{
///
/// Where the chat of a step may send data, from its start.
///
public static readonly OutboundDataRequirement STEP_REQUIREMENT = new(OutboundDataRestriction.ONLY_LINKS_FROM_CHAT, OutboundDataOrigin.BEYOND_FACTS_LAB, string.Empty);
///
/// The tools of the chat of a step.
///
private static readonly FrozenSet STEP_TOOL_IDS = FrozenSet.Create(StringComparer.Ordinal, ToolSelectionRules.READ_WEB_PAGE_TOOL_ID);
///
/// Gets the tools a chat of the lab offers the model.
///
/// Where the chat belongs.
/// The IDs of the tools; the request still leaves out every one which may not run.
public static IReadOnlySet For(BflThreadLocation location) => location is BflStepThreadLocation ? STEP_TOOL_IDS : FrozenSet.Empty;
///
/// Restricts where a chat of the lab may send data, as its place demands. The chat stores the restriction, and it
/// never gets looser.
///
/// The chat.
/// Where the chat belongs.
public static void Restrict(ChatThread thread, BflThreadLocation location)
{
if (location is BflStepThreadLocation)
thread.RequireOutboundDataRestriction(STEP_REQUIREMENT);
}
}