mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 22:21: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();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine(this.Text);
|
sb.AppendLine(this.Text);
|
||||||
|
|
||||||
if(this.FileAttachments.Count > 0)
|
if(this.FileAttachments.Count > 0)
|
||||||
{
|
{
|
||||||
sb.AppendLine();
|
// Check Pandoc availability once before processing file attachments
|
||||||
sb.AppendLine("The following files are attached to this message:");
|
var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false);
|
||||||
foreach(var file in this.FileAttachments)
|
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("---------------------------------------");
|
sb.AppendLine("The following files are attached to this message:");
|
||||||
sb.AppendLine($"File path: {file}");
|
foreach(var file in this.FileAttachments)
|
||||||
sb.AppendLine("File content:");
|
{
|
||||||
sb.AppendLine("````");
|
sb.AppendLine();
|
||||||
sb.AppendLine(await Program.RUST_SERVICE.ReadArbitraryFileData(file, int.MaxValue));
|
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();
|
return sb.ToString();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user