Added Latex support for chat attachments

This commit is contained in:
Paul Koudelka 2026-04-01 16:12:34 +02:00
parent b9380cc161
commit 1496b5e591
5 changed files with 13 additions and 6 deletions

View File

@ -82,17 +82,22 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
/// <returns>The corresponding FileAttachmentType.</returns>
private static FileAttachmentType DetermineFileType(string filePath)
{
// Check if it's an executable:
if (FileTypes.IsAllowedPath(filePath, FileTypes.EXECUTABLES))
return FileAttachmentType.FORBIDDEN;
// Check if it's an image file:
if (FileTypes.IsAllowedPath(filePath, FileTypes.IMAGE))
return FileAttachmentType.IMAGE;
// Check if it's an audio file
if (FileTypes.IsAllowedPath(filePath, FileTypes.AUDIO))
return FileAttachmentType.AUDIO;
return FileTypes.IsAllowedPath(filePath, FileTypes.DOCUMENT)
? FileAttachmentType.DOCUMENT
: FileAttachmentType.FORBIDDEN;
// Check if it's an allowed document file (PDF, Text, LaTeX, or Office):
if (FileTypes.IsAllowedPath(filePath, FileTypes.DOCUMENT))
return FileAttachmentType.DOCUMENT;
return FileAttachmentType.FORBIDDEN;
}
}

View File

@ -181,6 +181,7 @@ public partial class AttachDocuments : MSGComponentBase
{
if(!await FileExtensionValidation.IsExtensionValidWithNotifyAsync(FileExtensionValidation.UseCase.ATTACHING_CONTENT, path, this.ValidateMediaFileTypes, this.Provider))
continue;
this.DocumentPaths.Add(FileAttachment.FromPath(path));
}

View File

@ -96,7 +96,7 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId
private readonly List<Model> availableModels = new();
private readonly Encryption encryption = Program.ENCRYPTION;
private readonly ProviderValidation providerValidation;
public EmbeddingProviderDialog()
{
this.providerValidation = new()

View File

@ -49,11 +49,12 @@ public static class FileTypes
public static readonly FileTypeFilter EXCEL = FileTypeFilter.Leaf("Excel", "xls", "xlsx");
public static readonly FileTypeFilter POWER_POINT = FileTypeFilter.Leaf("PowerPoint", "ppt", "pptx");
public static readonly FileTypeFilter MAIL = FileTypeFilter.Leaf(TB("Mail"), "eml", "msg", "mbox");
public static readonly FileTypeFilter LATEX = FileTypeFilter.Leaf("LaTeX", "tex", "bib", "sty", "cls", "log");
public static readonly FileTypeFilter OFFICE_FILES = FileTypeFilter.Parent(TB("Office Files"),
WORD, EXCEL, POWER_POINT, PDF);
public static readonly FileTypeFilter DOCUMENT = FileTypeFilter.Parent(TB("Document"),
TEXT, OFFICE_FILES, SOURCE_CODE, MAIL);
TEXT, OFFICE_FILES, SOURCE_CODE, LATEX);
// Media hierarchy
public static readonly FileTypeFilter IMAGE = FileTypeFilter.Leaf(TB("Image"),

View File

@ -59,7 +59,7 @@ public sealed partial class RustService
/// Initiates a dialog to let the user select a file for a writing operation.
/// </summary>
/// <param name="title">The title of the save file dialog.</param>
/// <param name="filter">An optional file type filter for filtering specific file formats.</param>
/// <param name="filter">Optional file type filters for filtering specific file formats.</param>
/// <param name="initialFile">An optional initial file path to pre-fill in the dialog.</param>
/// <returns>A <see cref="FileSaveResponse"/> object containing information about whether the user canceled the
/// operation and whether the select operation was successful.</returns>