mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 06:01:37 +00:00
Ensure Pandoc availability check before processing files
This commit is contained in:
parent
8b0f5dfbf8
commit
34dd75bb40
@ -153,20 +153,27 @@ public sealed class ContentText : IContent
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(this.Text);
|
||||
|
||||
|
||||
if(this.FileAttachments.Count > 0)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("The following files are attached to this message:");
|
||||
foreach(var file in this.FileAttachments)
|
||||
// Check Pandoc availability once before processing file attachments
|
||||
var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false);
|
||||
if (!pandocState.IsAvailable || !pandocState.CheckWasSuccessful)
|
||||
LOGGER.LogWarning("File attachments could not be processed because Pandoc is not available or the version check failed.");
|
||||
else
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("---------------------------------------");
|
||||
sb.AppendLine($"File path: {file}");
|
||||
sb.AppendLine("File content:");
|
||||
sb.AppendLine("````");
|
||||
sb.AppendLine(await Program.RUST_SERVICE.ReadArbitraryFileData(file, int.MaxValue));
|
||||
sb.AppendLine("````");
|
||||
sb.AppendLine("The following files are attached to this message:");
|
||||
foreach(var file in this.FileAttachments)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("---------------------------------------");
|
||||
sb.AppendLine($"File path: {file}");
|
||||
sb.AppendLine("File content:");
|
||||
sb.AppendLine("````");
|
||||
sb.AppendLine(await Program.RUST_SERVICE.ReadArbitraryFileData(file, int.MaxValue));
|
||||
sb.AppendLine("````");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user