included allowProfiles and system prompt properties to the lua parser

This commit is contained in:
krut_ni 2025-09-30 21:54:24 +02:00
parent 09b187d3f7
commit 488747b762
2 changed files with 25 additions and 1 deletions

View File

@ -5356,12 +5356,18 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::PANDOC::T726914939"] = "The latest Pandoc vers
-- The ASSISTANT table does not contain a valid description.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T2080819991"] = "The ASSISTANT table does not contain a valid description."
-- The ASSISTANT table does not contain a the boolean flag to control the allowance of profiles.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T221472268"] = "The ASSISTANT table does not contain a the boolean flag to control the allowance of profiles."
-- Failed to parse the UI render tree.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T2583341941"] = "Failed to parse the UI render tree."
-- The ASSISTANT table does not contain a valid UI section.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3126717084"] = "The ASSISTANT table does not contain a valid UI section."
-- The ASSISTANT table does not contain a valid system prompt.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T3723171842"] = "The ASSISTANT table does not contain a valid system prompt."
-- The ASSISTANT table does not exist or is not a valid table.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::PLUGINSYSTEM::ASSISTANTS::PLUGINASSISTANTS::T6004146"] = "The ASSISTANT table does not exist or is not a valid table."

View File

@ -12,7 +12,9 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
public AssistantForm? RootComponent { get; set; }
public string AssistantTitle { get; set; } = string.Empty;
private string AssistantDescription { get; set; } = string.Empty;
public string AssistantDescription { get; set; } = string.Empty;
public string SystemPrompt { get; set; } = string.Empty;
public bool AllowProfiles { get; set; } = true;
public void TryLoad()
{
@ -55,8 +57,24 @@ public sealed class PluginAssistants(bool isInternal, LuaState state, PluginType
return false;
}
if (!assistantTable.TryGetValue("SystemPrompt", out var assistantSystemPromptValue) ||
!assistantSystemPromptValue.TryRead<string>(out var assistantSystemPrompt))
{
message = TB("The ASSISTANT table does not contain a valid system prompt.");
return false;
}
if (!assistantTable.TryGetValue("AllowProfiles", out var assistantAllowProfilesValue) ||
!assistantAllowProfilesValue.TryRead<bool>(out var assistantAllowProfiles))
{
message = TB("The ASSISTANT table does not contain a the boolean flag to control the allowance of profiles.");
return false;
}
this.AssistantTitle = assistantTitle;
this.AssistantDescription = assistantDescription;
this.SystemPrompt = assistantSystemPrompt;
this.AllowProfiles = assistantAllowProfiles;
// Ensure that the UI table exists nested in the ASSISTANT table and is a valid Lua table:
if (!assistantTable.TryGetValue("UI", out var uiVal) || !uiVal.TryRead<LuaTable>(out var uiTable))