mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 12:58:00 +00:00
Added direct-chat launchers for assistant plugins and a dialog to reconfigure them (#935)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
f03c2d1c88
commit
a4c35fc2f2
44 files changed
+2615
-219
No files matched your search
@@ -83,8 +83,7 @@ internal sealed partial class LuaResponse
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.Assistant.Title) ||
|
||||
string.IsNullOrWhiteSpace(this.Assistant.Description) ||
|
||||
string.IsNullOrWhiteSpace(this.Assistant.SystemPrompt) ||
|
||||
string.IsNullOrWhiteSpace(this.Assistant.SubmitText))
|
||||
!IsValidAssistantMetadata(this.Assistant))
|
||||
{
|
||||
error = LuaResponseParseError.INCOMPLETE_ASSISTANT_METADATA;
|
||||
return false;
|
||||
@@ -105,6 +104,38 @@ internal sealed partial class LuaResponse
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsValidAssistantMetadata(AssistantBuilderAssistantMetadata assistant) => assistant.Kind switch
|
||||
{
|
||||
"FORM" => !string.IsNullOrWhiteSpace(assistant.SystemPrompt) &&
|
||||
!string.IsNullOrWhiteSpace(assistant.SubmitText) &&
|
||||
assistant.AllowAiStudioProfiles.HasValue &&
|
||||
assistant.Launch is null,
|
||||
"CHAT_LAUNCHER" => assistant.SystemPrompt is null &&
|
||||
assistant.SubmitText is null &&
|
||||
assistant.AllowAiStudioProfiles is null &&
|
||||
IsValidChatLaunchMetadata(assistant.Launch),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
private static bool IsValidChatLaunchMetadata(AssistantBuilderChatLaunchMetadata? launch)
|
||||
{
|
||||
if (launch is null || string.IsNullOrWhiteSpace(launch.WorkspaceName))
|
||||
return false;
|
||||
|
||||
if (!IsOptionalGuid(launch.ProviderId, allowEmpty: false) ||
|
||||
!IsOptionalGuid(launch.ProfileId, allowEmpty: true) ||
|
||||
!IsOptionalGuid(launch.ChatTemplateId, allowEmpty: true))
|
||||
return false;
|
||||
|
||||
return launch.DataSourceIds is null ||
|
||||
launch.DataSourceIds.Length > 0 &&
|
||||
launch.DataSourceIds.All(id => Guid.TryParse(id, out var parsed) && parsed != Guid.Empty) &&
|
||||
launch.DataSourceIds.Distinct(StringComparer.OrdinalIgnoreCase).Count() == launch.DataSourceIds.Length;
|
||||
}
|
||||
|
||||
private static bool IsOptionalGuid(string? value, bool allowEmpty) => value is null ||
|
||||
Guid.TryParse(value, out var parsed) && (allowEmpty || parsed != Guid.Empty);
|
||||
|
||||
private static string ExtractJson(string input)
|
||||
{
|
||||
var start = input.IndexOf('{');
|
||||
|
||||
Reference in new issue
Block a user