mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-14 00:51:37 +00:00
Improved handling of file attachments in chats (#689)
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
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) (push) Has been cancelled
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) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
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) (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
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) (push) Has been cancelled
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) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
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) (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
parent
c120502215
commit
65ec82cdcb
@ -84,6 +84,9 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
|
||||
{
|
||||
var extension = Path.GetExtension(filePath).TrimStart('.').ToLowerInvariant();
|
||||
|
||||
if (FileTypeFilter.Executables.FilterExtensions.Contains(extension))
|
||||
return FileAttachmentType.FORBIDDEN;
|
||||
|
||||
// Check if it's an image file:
|
||||
if (FileTypeFilter.AllImages.FilterExtensions.Contains(extension))
|
||||
return FileAttachmentType.IMAGE;
|
||||
@ -96,7 +99,8 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi
|
||||
if (FileTypeFilter.PDF.FilterExtensions.Contains(extension) ||
|
||||
FileTypeFilter.Text.FilterExtensions.Contains(extension) ||
|
||||
FileTypeFilter.AllOffice.FilterExtensions.Contains(extension) ||
|
||||
FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension))
|
||||
FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension) ||
|
||||
FileTypeFilter.IsAllowedSourceLikeFileName(filePath))
|
||||
return FileAttachmentType.DOCUMENT;
|
||||
|
||||
// All other file types are forbidden:
|
||||
|
||||
@ -12,6 +12,51 @@ namespace AIStudio.Tools.Rust;
|
||||
public readonly record struct FileTypeFilter(string FilterName, string[] FilterExtensions)
|
||||
{
|
||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(FileTypeFilter).Namespace, nameof(FileTypeFilter));
|
||||
|
||||
private static string[] AllowedSourceLikeFileNames =>
|
||||
[
|
||||
"Dockerfile",
|
||||
"Containerfile",
|
||||
"Jenkinsfile",
|
||||
"Makefile",
|
||||
"GNUmakefile",
|
||||
"Procfile",
|
||||
"Vagrantfile",
|
||||
"Tiltfile",
|
||||
"Justfile",
|
||||
"Brewfile",
|
||||
"Caddyfile",
|
||||
"Gemfile",
|
||||
"Podfile",
|
||||
"Fastfile",
|
||||
"Appfile",
|
||||
"Rakefile",
|
||||
"Dangerfile",
|
||||
"BUILD",
|
||||
"WORKSPACE",
|
||||
"BUCK",
|
||||
];
|
||||
|
||||
private static string[] AllowedSourceLikeFileNamePrefixes =>
|
||||
[
|
||||
"Dockerfile",
|
||||
"Containerfile",
|
||||
"Jenkinsfile",
|
||||
"Procfile",
|
||||
"Caddyfile",
|
||||
];
|
||||
|
||||
public static bool IsAllowedSourceLikeFileName(string filePath)
|
||||
{
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
return false;
|
||||
|
||||
if (AllowedSourceLikeFileNames.Any(name => string.Equals(name, fileName, StringComparison.OrdinalIgnoreCase)))
|
||||
return true;
|
||||
|
||||
return AllowedSourceLikeFileNamePrefixes.Any(prefix => fileName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public static FileTypeFilter PDF => new(TB("PDF Files"), ["pdf"]);
|
||||
|
||||
|
||||
@ -7,5 +7,6 @@
|
||||
- Improved the user-language logging by limiting language detection logs to a single entry per app start.
|
||||
- Improved the logbook readability by removing non-readable special characters from log entries.
|
||||
- Improved the logbook reliability by significantly reducing duplicate log entries.
|
||||
- Improved file attachments in chats: configuration and project files such as `Dockerfile`, `Caddyfile`, `Makefile`, or `Jenkinsfile` are now included more reliably when you send them to the AI.
|
||||
- Improved the validation of additional API parameters in the advanced provider settings to help catch formatting mistakes earlier.
|
||||
- Fixed an issue where the app could turn white or appear invisible in certain chats after HTML-like content was shown. Thanks Inga for reporting this issue and providing some context on how to reproduce it.
|
||||
Loading…
Reference in New Issue
Block a user