mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-13 06:53:48 +00:00
Added simple assistant plugin example (#734)
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,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,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,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,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Publish release (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,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,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,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,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
1 parent
da62814b2f
commit
e5d8ac4a71
13 files changed
+423
-24
No files matched your search
+48
@@ -10,6 +10,11 @@ internal static class AssistantLuaConversion
|
||||
/// </summary>
|
||||
public static LuaTable CreateLuaArray(IEnumerable values) => CreateLuaArrayCore(values);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a readable string representation of a Lua table for debugging and inspection.
|
||||
/// </summary>
|
||||
public static string InspectTable(LuaTable table) => InspectTableCore(table, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a Lua value into either a scalar .NET value or one of the structured assistant data model types.
|
||||
/// Lua itself only exposes scalars and tables, so structured assistant types such as dropdown/list items
|
||||
@@ -268,4 +273,47 @@ internal static class AssistantLuaConversion
|
||||
|
||||
return luaArray;
|
||||
}
|
||||
|
||||
private static string InspectTableCore(LuaTable table, int depth)
|
||||
{
|
||||
if (depth > 8)
|
||||
return "{ ... }";
|
||||
|
||||
var indent = new string(' ', depth * 2);
|
||||
var childIndent = new string(' ', (depth + 1) * 2);
|
||||
var builder = new System.Text.StringBuilder();
|
||||
builder.AppendLine("{");
|
||||
|
||||
foreach (var entry in table)
|
||||
{
|
||||
builder.Append(childIndent);
|
||||
builder.Append(FormatLuaValue(entry.Key));
|
||||
builder.Append(" = ");
|
||||
builder.AppendLine(FormatLuaValue(entry.Value, depth + 1));
|
||||
}
|
||||
|
||||
builder.Append(indent);
|
||||
builder.Append('}');
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static string FormatLuaValue(LuaValue value, int depth = 0)
|
||||
{
|
||||
if (value.Type is LuaValueType.Nil)
|
||||
return "nil";
|
||||
|
||||
if (value.TryRead<string>(out var stringValue))
|
||||
return $"\"{stringValue.Replace("\\", "\\\\").Replace("\"", "\\\"")}\"";
|
||||
|
||||
if (value.TryRead<bool>(out var boolValue))
|
||||
return boolValue ? "true" : "false";
|
||||
|
||||
if (value.TryRead<double>(out var doubleValue))
|
||||
return doubleValue.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
if (value.TryRead<LuaTable>(out var tableValue))
|
||||
return InspectTableCore(tableValue, depth);
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user