Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat: expand supported file types for document attachments to include many other extensions (#7859)

Tonyfecf314db0a5
diff --git a/src-tauri/plugins/tauri-plugin-rag/src/parser.rs b/src-tauri/plugins/tauri-plugin-rag/src/parser.rs
index 9f1604ef2..59a8d527e 100644
--- a/src-tauri/plugins/tauri-plugin-rag/src/parser.rs
+++ b/src-tauri/plugins/tauri-plugin-rag/src/parser.rs
@@ -67,22 +67,26 @@ pub fn parse_document(file_path: &str, file_type: &str) -> Result<String, RagErr
// Systems languages
| "rs" | "go" | "swift" | "zig"
// JVM languages
- | "java" | "kt" | "kts" | "scala" | "groovy"
+ | "java" | "kt" | "kts" | "scala" | "groovy" | "clj" | "cljs" | "hs" | "lhs" | "ml" | "mli" | "f" | "f77" | "f90" | "f95" | "f03" | "f08"
// Scripting languages
- | "rb" | "php" | "lua" | "pl" | "pm" | "r" | "jl"
+ | "rb" | "php" | "lua" | "pl" | "pm" | "r" | "jl" | "vbs" | "asm" | "s" | "m" | "mm" | "pas" | "pp" | "erl" | "hrl" | "ex" | "exs"
// .NET
- | "cs" | "fs" | "vb"
+ | "cs" | "fs" | "vb" | "xaml" | "csproj" | "sln"
+ // CUDA
+ | "cu" | "cuh"
+ // Shaders
+ | "hlsl" | "glsl" | "cg" | "shader"
// Shell
- | "sh" | "bash" | "zsh" | "fish" | "ps1" | "psm1"
+ | "sh" | "bash" | "zsh" | "fish" | "ps1" | "psm1" | "bat" | "cmd"
// Web
- | "css" | "scss" | "sass" | "less" | "vue" | "svelte" | "astro"
+ | "css" | "scss" | "sass" | "less" | "vue" | "svelte" | "astro" | "asp" | "aspx" | "jsp"
// Data / config formats
| "json" | "jsonc" | "yaml" | "yml" | "toml" | "xml" | "ini"
- | "cfg" | "conf" | "config" | "env" | "properties"
+ | "cfg" | "conf" | "config" | "env" | "properties" | "lock"
// Query / markup
- | "sql" | "graphql" | "gql" | "tex" | "rst" | "adoc"
+ | "sql" | "graphql" | "gql" | "tex" | "rst" | "adoc" | "textile"
// Misc text
- | "log" | "diff" | "patch" | "gitignore" | "dockerfile" | "makefile" => parse_text(file_path),
+ | "log" | "diff" | "patch" | "gitignore" | "dockerfile" | "makefile" | "cmake" => parse_text(file_path),
"csv" | "text/csv" => parse_csv(file_path),
// Excel family via calamine
"xlsx"
diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsx
index 74cbd1e3e..aea4b3888 100644
--- a/web-app/src/containers/ChatInput.tsx
+++ b/web-app/src/containers/ChatInput.tsx
@@ -855,12 +855,45 @@ const ChatInput = memo(function ChatInput({
'cs',
'fs',
'vb',
+ 'xaml',
+ 'csproj',
+ 'sln',
+ // CUDA
+ 'cu',
+ 'cuh',
+ // Shaders
+ 'hlsl',
+ 'glsl',
+ 'cg',
+ 'shader',
// Shell
'sh',
'bash',
'zsh',
'fish',
'ps1',
+ 'bat',
+ 'cmd',
+ 'vbs',
+ // More languages
+ 'asm',
+ 's',
+ 'm',
+ 'mm',
+ 'pas',
+ 'pp',
+ 'erl',
+ 'hrl',
+ 'ex',
+ 'exs',
+ 'clj',
+ 'cljs',
+ 'hs',
+ 'lhs',
+ 'ml',
+ 'mli',
+ 'f',
+ 'f90',
// Web
'css',
'scss',
@@ -869,6 +902,10 @@ const ChatInput = memo(function ChatInput({
'vue',
'svelte',
'astro',
+ 'php',
+ 'asp',
+ 'aspx',
+ 'jsp',
// Data / config formats
'json',
'jsonc',
@@ -880,16 +917,24 @@ const ChatInput = memo(function ChatInput({
'cfg',
'conf',
'env',
+ 'properties',
+ 'dockerfile',
+ 'makefile',
+ 'cmake',
+ 'lock',
// Query / markup
'sql',
'graphql',
'gql',
'tex',
'rst',
+ 'adoc',
+ 'textile',
// Misc text
'log',
'diff',
'patch',
+ 'gitignore',
],
},
{
diff --git a/web-app/src/containers/ProjectFiles.tsx b/web-app/src/containers/ProjectFiles.tsx
index 66830d42e..5667377ea 100644
--- a/web-app/src/containers/ProjectFiles.tsx
+++ b/web-app/src/containers/ProjectFiles.tsx
@@ -98,12 +98,45 @@ const SUPPORTED_EXTENSIONS = [
'cs',
'fs',
'vb',
- // Shell
+ 'xaml',
+ 'csproj',
+ 'sln',
+ // CUDA
+ 'cu',
+ 'cuh',
+ // Shaders
+ 'hlsl',
+ 'glsl',
+ 'cg',
+ 'shader',
+ // Shell / Scripting
'sh',
'bash',
'zsh',
'fish',
'ps1',
+ 'bat',
+ 'cmd',
+ 'vbs',
+ // More languages
+ 'asm',
+ 's',
+ 'm',
+ 'mm',
+ 'pas',
+ 'pp',
+ 'erl',
+ 'hrl',
+ 'ex',
+ 'exs',
+ 'clj',
+ 'cljs',
+ 'hs',
+ 'lhs',
+ 'ml',
+ 'mli',
+ 'f',
+ 'f90',
// Web
'css',
'scss',
@@ -112,6 +145,10 @@ const SUPPORTED_EXTENSIONS = [
'vue',
'svelte',
'astro',
+ 'php',
+ 'asp',
+ 'aspx',
+ 'jsp',
// Data / config formats
'json',
'jsonc',
@@ -123,16 +160,24 @@ const SUPPORTED_EXTENSIONS = [
'cfg',
'conf',
'env',
+ 'properties',
+ 'dockerfile',
+ 'makefile',
+ 'cmake',
+ 'lock',
// Query / markup
'sql',
'graphql',
'gql',
'tex',
'rst',
+ 'adoc',
+ 'textile',
// Misc text
'log',
'diff',
'patch',
+ 'gitignore',
]
async function getFilesFromPaths(paths: string[]): Promise<string[]> {
@@ -237,10 +282,11 @@ export default function ProjectFiles({ projectId, lng }: ProjectFilesProps) {
// Filter unsupported file types
if (!fileType || !SUPPORTED_EXTENSIONS.includes(fileType)) {
toast.warning(
- t('common:toast.unsupportedFileType.title') ??
- 'Unsupported file type',
+ t('common:toast.unsupportedFileType.title'),
{
- description: name,
+ description: t('common:toast.unsupportedFileType.description', {
+ extension: fileType || 'unknown',
+ }),
}
)
continue
diff --git a/web-app/src/locales/en/common.json b/web-app/src/locales/en/common.json
index 95df729cb..630347d0b 100644
--- a/web-app/src/locales/en/common.json
+++ b/web-app/src/locales/en/common.json
@@ -439,6 +439,10 @@
"title": "File Already Exists",
"description": "File is already attached to this project"
},
+ "unsupportedFileType": {
+ "title": "Unsupported File Type",
+ "description": "File extension \".{{extension}}\" is not supported for Project reference."
+ },
"attachmentsDisabledInfo": {
"title": "Attachments Disabled",
"description": "Attachments are disabled in Settings"