mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-12 07:47:21 +00:00
Generated the JSON contracts of visual briefings and model answers at compile time (#1151)
This commit is contained in:
1 parent
24e3c22db3
commit
770c16e20a
101 files changed
+2333
-392
No files matched your search
@@ -2,12 +2,12 @@ namespace AIStudio.Assistants.Builder;
|
||||
|
||||
internal sealed class AssistantBuilderAssistantMetadata
|
||||
{
|
||||
public string Kind { get; init; } = string.Empty;
|
||||
public string Title { get; init; } = string.Empty;
|
||||
public string Description { get; init; } = string.Empty;
|
||||
public string? SystemPrompt { get; init; }
|
||||
public string? SubmitText { get; init; }
|
||||
public bool? AllowAiStudioProfiles { get; init; }
|
||||
public string[]? ToolIds { get; init; }
|
||||
public AssistantBuilderChatLaunchMetadata? Launch { get; init; }
|
||||
public string Kind { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string? SystemPrompt { get; set; }
|
||||
public string? SubmitText { get; set; }
|
||||
public bool? AllowAiStudioProfiles { get; set; }
|
||||
public string[]? ToolIds { get; set; }
|
||||
public AssistantBuilderChatLaunchMetadata? Launch { get; set; }
|
||||
}
|
||||
@@ -6,10 +6,10 @@ internal sealed class AssistantBuilderChatLaunchMetadata
|
||||
/// The workspace the chat is created in. A model leaves this field out for a launcher that
|
||||
/// opens a chat without a workspace, which is why it stays empty rather than null.
|
||||
/// </summary>
|
||||
public string WorkspaceName { get; init; } = string.Empty;
|
||||
public string? ProviderId { get; init; }
|
||||
public string? ProfileId { get; init; }
|
||||
public string? ChatTemplateId { get; init; }
|
||||
public string[]? DataSourceIds { get; init; }
|
||||
public string[]? ToolIds { get; init; }
|
||||
public string WorkspaceName { get; set; } = string.Empty;
|
||||
public string? ProviderId { get; set; }
|
||||
public string? ProfileId { get; set; }
|
||||
public string? ChatTemplateId { get; set; }
|
||||
public string[]? DataSourceIds { get; set; }
|
||||
public string[]? ToolIds { get; set; }
|
||||
}
|
||||
@@ -2,7 +2,7 @@ namespace AIStudio.Assistants.Builder;
|
||||
|
||||
internal sealed class AssistantBuilderPluginMetadata
|
||||
{
|
||||
public string Name { get; init; } = string.Empty;
|
||||
public string Description { get; init; } = string.Empty;
|
||||
public string[] Categories { get; init; } = [];
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string[] Categories { get; set; } = [];
|
||||
}
|
||||
@@ -14,30 +14,31 @@ internal sealed class LauncherTextsResponse
|
||||
{
|
||||
public const string SCHEMA_VERSION_VALUE = "assistant_builder_launcher_texts_v1";
|
||||
|
||||
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
||||
internal static readonly JsonSerializerOptions JSON_OPTIONS = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
AllowTrailingCommas = false,
|
||||
ReadCommentHandling = JsonCommentHandling.Disallow,
|
||||
MaxDepth = 8,
|
||||
};
|
||||
TypeInfoResolver = LauncherTextsResponseJsonContext.Default,
|
||||
}.AsReadOnly();
|
||||
|
||||
public string SchemaVersion { get; init; } = string.Empty;
|
||||
public string SchemaVersion { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The plugin name, shown on the plugins page.
|
||||
/// </summary>
|
||||
public string PluginName { get; init; } = string.Empty;
|
||||
public string PluginName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The title on the tile.
|
||||
/// </summary>
|
||||
public string Title { get; init; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The short description, used for both the plugin and the tile.
|
||||
/// </summary>
|
||||
public string Description { get; init; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public static bool TryParse(string modelResponse, out LauncherTextsResponse response, out LuaResponseParseError error, out string technicalDetails)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AIStudio.Assistants.Builder;
|
||||
|
||||
/// <summary>
|
||||
/// The contracts with which System.Text.Json reads the answer of a model which names a direct chat launcher, built
|
||||
/// at compile time.
|
||||
/// </summary>
|
||||
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata)]
|
||||
[JsonSerializable(typeof(LauncherTextsResponse))]
|
||||
internal sealed partial class LauncherTextsResponseJsonContext : JsonSerializerContext;
|
||||
@@ -4,13 +4,14 @@ namespace AIStudio.Assistants.Builder;
|
||||
|
||||
internal sealed partial class LuaResponse
|
||||
{
|
||||
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
||||
internal static readonly JsonSerializerOptions JSON_OPTIONS = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
AllowTrailingCommas = false,
|
||||
ReadCommentHandling = JsonCommentHandling.Disallow,
|
||||
MaxDepth = 32,
|
||||
};
|
||||
TypeInfoResolver = LuaResponseJsonContext.Default,
|
||||
}.AsReadOnly();
|
||||
|
||||
public static bool TryParse(string modelResponse, out LuaResponse response, out LuaResponseParseError error, out string technicalDetails)
|
||||
{
|
||||
|
||||
@@ -3,8 +3,8 @@ namespace AIStudio.Assistants.Builder;
|
||||
internal sealed partial class LuaResponse
|
||||
{
|
||||
public const string SCHEMA_VERSION_VALUE = "assistant_builder_lua_response_v2";
|
||||
public string SchemaVersion { get; init; } = string.Empty;
|
||||
public AssistantBuilderPluginMetadata? Plugin { get; init; }
|
||||
public AssistantBuilderAssistantMetadata? Assistant { get; init; }
|
||||
public string FullLua { get; init; } = string.Empty;
|
||||
public string SchemaVersion { get; set; } = string.Empty;
|
||||
public AssistantBuilderPluginMetadata? Plugin { get; set; }
|
||||
public AssistantBuilderAssistantMetadata? Assistant { get; set; }
|
||||
public string FullLua { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AIStudio.Assistants.Builder;
|
||||
|
||||
/// <summary>
|
||||
/// The contracts with which System.Text.Json reads the answer of a model which writes an assistant plugin, built at
|
||||
/// compile time.
|
||||
/// </summary>
|
||||
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata)]
|
||||
[JsonSerializable(typeof(LuaResponse))]
|
||||
internal sealed partial class LuaResponseJsonContext : JsonSerializerContext;
|
||||
Reference in new issue
Block a user