mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-29 17:23:38 +00:00
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using System.Text.Encodings.Web;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Nodes;
|
|
|
|
using AIStudio.Provider;
|
|
using AIStudio.Settings.DataModel;
|
|
|
|
namespace AIStudio.Tools.ToolCallingSystem;
|
|
|
|
public sealed class ToolExecutionResult
|
|
{
|
|
/// <summary>
|
|
/// How a JSON result is written for the model.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The result goes into the request as a string, and the request is serialized once more on its
|
|
/// way to the provider, so the model reads whatever this escapes as the escape itself. The
|
|
/// default encoder escapes every character outside ASCII and those HTML treats specially, for
|
|
/// JSON embedded in a web page, which this never is: a German document would reach the model
|
|
/// with every umlaut as six characters. The relaxed encoder escapes only what JSON requires.
|
|
/// </remarks>
|
|
private static readonly JsonSerializerOptions MODEL_CONTENT_OPTIONS = new() { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
|
|
|
|
public string? TextContent { get; init; }
|
|
|
|
public JsonNode? JsonContent { get; init; }
|
|
|
|
public IReadOnlyList<Source> Sources { get; init; } = [];
|
|
|
|
public ConfidenceLevel RequiredProviderConfidence { get; init; } = ConfidenceLevel.NONE;
|
|
|
|
/// <summary>
|
|
/// The data security the chat has to keep from now on, because of what this result brings in.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The other axis next to RequiredProviderConfidence. A data source which may only be used with
|
|
/// self-hosted providers says so here, and the chat then refuses every other provider from now
|
|
/// on, see ChatThread.RequireDataSecurity. Left at NOT_SPECIFIED, the result says nothing about
|
|
/// it, and the chat stays as it was.
|
|
/// </remarks>
|
|
public DataSourceSecurity RequiredDataSecurity { get; init; } = DataSourceSecurity.NOT_SPECIFIED;
|
|
|
|
public string ToModelContent()
|
|
{
|
|
if (this.JsonContent is not null)
|
|
return this.JsonContent.ToJsonString(MODEL_CONTENT_OPTIONS);
|
|
|
|
return this.TextContent ?? string.Empty;
|
|
}
|
|
} |