mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 20:32:11 +00:00
105 lines
2.7 KiB
C#
105 lines
2.7 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Nodes;
|
|
using System.Text.Json.Serialization;
|
|
|
|
using AIStudio.Provider;
|
|
using AIStudio.Settings;
|
|
|
|
namespace AIStudio.Tools.ToolCallingSystem;
|
|
|
|
public sealed class ToolExecutionContext
|
|
{
|
|
public required ToolDefinition Definition { get; init; }
|
|
|
|
public string ToolCallId { get; init; } = string.Empty;
|
|
|
|
public required SettingsManager SettingsManager { get; init; }
|
|
|
|
public required IReadOnlyDictionary<string, string> SettingsValues { get; init; }
|
|
|
|
public ConfidenceLevel ProviderConfidence { get; init; } = ConfidenceLevel.UNKNOWN;
|
|
}
|
|
|
|
public sealed class ToolExecutionResult
|
|
{
|
|
public string? TextContent { get; init; }
|
|
|
|
public JsonNode? JsonContent { get; init; }
|
|
|
|
public IReadOnlyList<Source> Sources { get; init; } = [];
|
|
|
|
public ConfidenceLevel RequiredProviderConfidence { get; init; } = ConfidenceLevel.NONE;
|
|
|
|
public string ToModelContent()
|
|
{
|
|
if (this.JsonContent is not null)
|
|
return this.JsonContent.ToJsonString();
|
|
|
|
return this.TextContent ?? string.Empty;
|
|
}
|
|
}
|
|
|
|
public sealed class ToolExecutionBlockedException(string message) : Exception(message);
|
|
|
|
public enum ToolInvocationTraceStatus
|
|
{
|
|
NONE = 0,
|
|
SUCCESS,
|
|
ERROR,
|
|
BLOCKED,
|
|
}
|
|
|
|
public sealed class ToolInvocationTrace
|
|
{
|
|
public int Order { get; set; }
|
|
|
|
public string ToolId { get; set; } = string.Empty;
|
|
|
|
public string ToolName { get; set; } = string.Empty;
|
|
|
|
public string ToolIcon { get; set; } = Icons.Material.Filled.Build;
|
|
|
|
public string ToolCallId { get; set; } = string.Empty;
|
|
|
|
public ToolInvocationTraceStatus Status { get; set; } = ToolInvocationTraceStatus.NONE;
|
|
|
|
public bool WasExecuted { get; set; }
|
|
|
|
public string StatusMessage { get; set; } = string.Empty;
|
|
|
|
public Dictionary<string, string> Arguments { get; set; } = [];
|
|
|
|
[JsonIgnore]
|
|
public string Result { get; set; } = string.Empty;
|
|
|
|
[JsonIgnore]
|
|
public JsonNode? JsonResult { get; set; }
|
|
}
|
|
|
|
public sealed class ToolConfigurationState
|
|
{
|
|
public bool IsConfigured { get; init; }
|
|
|
|
public List<string> MissingRequiredFields { get; init; } = [];
|
|
|
|
public string Message { get; init; } = string.Empty;
|
|
}
|
|
|
|
public sealed class ToolCatalogItem
|
|
{
|
|
public required ToolDefinition Definition { get; init; }
|
|
|
|
public required IToolImplementation Implementation { get; init; }
|
|
|
|
public required ToolConfigurationState ConfigurationState { get; init; }
|
|
|
|
public bool IsActive { get; init; }
|
|
|
|
public ConfidenceLevel MinimumProviderConfidence { get; init; } = ConfidenceLevel.NONE;
|
|
}
|
|
|
|
public sealed class ToolSelectionState
|
|
{
|
|
public HashSet<string> SelectedToolIds { get; init; } = [];
|
|
}
|