From 0244ab851e35fc5fe9efe65a9592d624d316499c Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 5 Feb 2025 10:05:22 -0500 Subject: [PATCH] fix --- Modelfile | 2 +- electron-file-search/README.md | 2 +- electron-file-search/electron/main.ts | 4 +- electron-file-search/electron/preload.ts | 3 +- .../electron/services/llmService.ts | 4 +- electron-file-search/index.html | 2 +- electron-file-search/package.json | 5 +- electron-file-search/src/App.tsx | 179 ++++++++++- .../src/components/ChatPanel/MessageList.tsx | 304 ++++++++++++++---- .../FileExplorer/DirectoryPicker.tsx | 54 +++- .../src/components/HomePanel/index.tsx | 2 +- .../src/components/OllamaCheck.tsx | 25 +- electron-file-search/src/index.css | 14 +- electron-file-search/vite.config.ts | 16 +- 14 files changed, 504 insertions(+), 112 deletions(-) diff --git a/Modelfile b/Modelfile index 5bb9d72..aeaf0b3 100644 --- a/Modelfile +++ b/Modelfile @@ -1,3 +1,3 @@ -FROM deepseek-r1:8b +FROM deepseek-r1:1.5b SYSTEM You are a helpful AI assistant. PARAMETER num_gpu 0 diff --git a/electron-file-search/README.md b/electron-file-search/README.md index fbb90bf..6ff378a 100644 --- a/electron-file-search/README.md +++ b/electron-file-search/README.md @@ -1,4 +1,4 @@ -# Data Hound +# Data Identification Manager : Personal Edition An Electron-based desktop application that uses AI to help you search and understand your files through natural language queries. diff --git a/electron-file-search/electron/main.ts b/electron-file-search/electron/main.ts index 2998036..b007864 100644 --- a/electron-file-search/electron/main.ts +++ b/electron-file-search/electron/main.ts @@ -12,6 +12,8 @@ function createWindow() { const mainWindow = new BrowserWindow({ width: 1200, height: 800, + minWidth: 1200, // Minimum width + minHeight: 800, // Minimum height frame: false, titleBarStyle: 'hidden', webPreferences: { @@ -40,7 +42,7 @@ function createWindow() { const response = await fetch(process.env.VITE_DEV_SERVER_URL); if (response.ok) { mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL); - mainWindow.webContents.openDevTools(); + //mainWindow.webContents.openDevTools(); } else { setTimeout(pollDevServer, 500); } diff --git a/electron-file-search/electron/preload.ts b/electron-file-search/electron/preload.ts index 0dec560..cf0b6df 100644 --- a/electron-file-search/electron/preload.ts +++ b/electron-file-search/electron/preload.ts @@ -1,6 +1,7 @@ const { contextBridge, ipcRenderer } = require('electron'); // Import types +import type { IpcRendererEvent } from 'electron'; import type { LLMConfig, DocumentMetadata } from './types'; interface Directory { @@ -73,7 +74,7 @@ contextBridge.exposeInMainWorld('electron', { checkModel: (modelName: string) => ipcRenderer.invoke('check-model', modelName), pullModel: (modelName: string, onProgress: (status: string) => void) => { const channel = `pull-model-progress-${modelName}`; - ipcRenderer.on(channel, (_event, status) => onProgress(status)); + ipcRenderer.on(channel, (_event: IpcRendererEvent, status: string) => onProgress(status)); return ipcRenderer.invoke('pull-model', modelName).finally(() => { ipcRenderer.removeListener(channel, onProgress); }); diff --git a/electron-file-search/electron/services/llmService.ts b/electron-file-search/electron/services/llmService.ts index bb33058..365f0b6 100644 --- a/electron-file-search/electron/services/llmService.ts +++ b/electron-file-search/electron/services/llmService.ts @@ -12,7 +12,7 @@ export class LLMService { ): Promise<{ answer: string, sources: DocumentMetadata[] }> { try { const ollamaResponse = await ollamaService.chat({ - model: 'damien113/datahound:latest', + model: 'damien113/datahound-gpu:8b', messages: [{ role: 'user', content: question }], temperature: 0.7, onChunk, @@ -36,7 +36,7 @@ export class LLMService { getConfig() { return { provider: 'ollama', - model: 'damien113/datahound:latest', + model: 'damien113/datahound-gpu:8b', baseUrl: 'http://localhost:11434', temperature: 0.7 }; diff --git a/electron-file-search/index.html b/electron-file-search/index.html index 4ee49bf..26e3978 100644 --- a/electron-file-search/index.html +++ b/electron-file-search/index.html @@ -4,7 +4,7 @@ - Data Hound + Data Identification Manager : Personal Edition
diff --git a/electron-file-search/package.json b/electron-file-search/package.json index 9a4474b..af37ad2 100644 --- a/electron-file-search/package.json +++ b/electron-file-search/package.json @@ -41,14 +41,15 @@ "dist-electron/**/*" ], "win": { - "target": "nsis" + "target": "portable" }, "mac": { "target": "dmg" }, "linux": { "target": "AppImage" - } + }, + "forceCodeSigning": false }, "devDependencies": { "@types/node": "^20.11.16", diff --git a/electron-file-search/src/App.tsx b/electron-file-search/src/App.tsx index db53604..aa208ec 100644 --- a/electron-file-search/src/App.tsx +++ b/electron-file-search/src/App.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import { Box, CssBaseline, ThemeProvider, createTheme, Tabs, Tab, TextField, IconButton } from '@mui/material'; -import { Send as SendIcon, DeleteOutline as ClearIcon, Close as CloseIcon, Remove as MinimizeIcon, Fullscreen as MaximizeIcon } from '@mui/icons-material'; +import { Box, CssBaseline, ThemeProvider, createTheme, Tabs, Tab, TextField, IconButton, Typography, Grow, Tooltip, Button, Chip } from '@mui/material'; +import { Send as SendIcon, DeleteOutline as ClearIcon, Close as CloseIcon, Remove as MinimizeIcon, Fullscreen as MaximizeIcon, Download, UpgradeTwoTone, OpenInBrowser } from '@mui/icons-material'; import { useChat } from './hooks/useChat'; import ChatPanel from './components/ChatPanel'; import FileExplorer from './components/FileExplorer'; @@ -97,6 +97,9 @@ function AppContent() { await sendMessage(message); }; + const handleClick = () => { + window.open('https://data443.com', '_blank'); + }; return ( @@ -111,7 +114,7 @@ function AppContent() { {/* Custom titlebar */} -
+ + + + + Data Identification Manager + +
+
- (thought for {thinkingTime}s) + (thought for {thinkingTime}ms)
+ {segment} +
); @@ -247,16 +271,178 @@ export default function MessageList({ messages }: MessageListProps) { ))}
)} - - {new Date(message.timestamp).toLocaleTimeString()} - ))} + + ):( + <> + + + )} ); } + + + +const WelcomeMessage = () => { + const [text, setText] = useState(''); + const fullText = 'Send a message...'; + const [showCursor, setShowCursor] = useState(true); + const theme = useTheme(); + + useEffect(() => { + if (text.length < fullText.length) { + const timeout = setTimeout(() => { + setText(fullText.slice(0, text.length + 1)); + }, 100); + return () => clearTimeout(timeout); + } + }, [text]); + + useEffect(() => { + const cursorInterval = setInterval(() => { + setShowCursor(prev => !prev); + }, 530); + return () => clearInterval(cursorInterval); + }, []); + + return ( + + + {/* Animated Keyboard and Hands */} + + + + + + + + {/* Typing Animation */} + + {text} + + | + + + + {/* Example Questions */} + + + + + + + + + + + + + + + + + + + + + + + + {/* Footer Note */} + + Ask me anything about your data, security needs, or Data443 products + + + + ); +}; diff --git a/electron-file-search/src/components/FileExplorer/DirectoryPicker.tsx b/electron-file-search/src/components/FileExplorer/DirectoryPicker.tsx index 9b437f0..b83594e 100644 --- a/electron-file-search/src/components/FileExplorer/DirectoryPicker.tsx +++ b/electron-file-search/src/components/FileExplorer/DirectoryPicker.tsx @@ -13,6 +13,9 @@ import { Alert, Box, Typography, + InputAdornment, + IconButton, + TextField, } from '@mui/material'; import { Folder as FolderIcon, @@ -21,6 +24,8 @@ import { Cloud as DropboxIcon, Chat as DiscordIcon, Computer as LocalIcon, + X, + Search, } from '@mui/icons-material'; import { useElectron } from '../../hooks/useElectron'; @@ -105,16 +110,48 @@ export default function DirectoryPicker({ onSelect }: DirectoryPickerProps) { mr: 2, mb: 2, }}> - Folders - diff --git a/electron-file-search/src/components/HomePanel/index.tsx b/electron-file-search/src/components/HomePanel/index.tsx index fc20d0d..c43b799 100644 --- a/electron-file-search/src/components/HomePanel/index.tsx +++ b/electron-file-search/src/components/HomePanel/index.tsx @@ -15,7 +15,7 @@ const HomePanel = () => { }}> - Welcome to Data Hound + Welcome to Data Identification Manager This application helps you search through your files and interact with their contents using AI assistance. diff --git a/electron-file-search/src/components/OllamaCheck.tsx b/electron-file-search/src/components/OllamaCheck.tsx index ac185d7..4f5a512 100644 --- a/electron-file-search/src/components/OllamaCheck.tsx +++ b/electron-file-search/src/components/OllamaCheck.tsx @@ -19,7 +19,7 @@ const theme = createTheme({ }); interface OllamaCheckProps { - onInstalled: () => void; + onInstalled: (arg:boolean) => void; } interface OllamaStatus { @@ -37,7 +37,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { const [modelStatus, setModelStatus] = useState(null); const [isChecking, setIsChecking] = useState(true); const [downloadProgress, setDownloadProgress] = useState(0); - const MODEL_NAME = 'damien113/datahound:latest'; + const MODEL_NAME = 'damien113/datahound-gpu:8b'; const checkOllama = async () => { try { @@ -53,16 +53,20 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { } }; - const checkModel = async () => { + const checkModel = async (retries = 3) => { try { const status = await window.electron.checkModel(MODEL_NAME); setModelStatus(status); if (status.installed) { - onInstalled(); + onInstalled(true); } } catch (error) { console.error('Error checking model:', error); - setModelStatus({ installed: false, installing: false }); + if (retries > 0) { + setTimeout(() => checkModel(retries - 1), 2000); + } else { + setModelStatus({ installed: false, installing: false }); + } } }; @@ -72,6 +76,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { try { // Set initial installation state once at the start setModelStatus({ installed: false, installing: true }); + onInstalled(false); setInstallError(null); setDownloadProgress(0); let downloadComplete = false; @@ -96,7 +101,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { // Show verification screen for a moment before transitioning await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay setModelStatus({ installed: true, installing: false }); - onInstalled(); + onInstalled(true); return; } @@ -108,6 +113,8 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { } catch (error) { console.error('Error installing model:', error); setModelStatus({ installed: false, installing: false }); + + onInstalled(false); setInstallError(error instanceof Error ? error.message : 'Unknown error occurred'); setDownloadProgress(0); } @@ -126,7 +133,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { if (!ollamaStatus?.installed || !ollamaStatus?.running) { checkOllama(); } - }, 5000); + }, 2000); // Cleanup interval on unmount return () => clearInterval(interval); @@ -236,7 +243,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { color: 'text.primary', }}> - {modelStatus?.installing ? 'Installing Data Hound AI Model' : 'AI Model Required'} + {modelStatus?.installing ? 'Installing Data Identification Manager AI Model' : 'AI Model Required'} {installError && ( @@ -284,7 +291,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) { fontSize: '1.1rem', }} > - Download Data Hound AI Model + Download Data Identification Manager AI Model )} diff --git a/electron-file-search/src/index.css b/electron-file-search/src/index.css index 079198a..900067f 100644 --- a/electron-file-search/src/index.css +++ b/electron-file-search/src/index.css @@ -33,7 +33,7 @@ html, body { .thinking-section { border-radius: 8px; - margin: 0 0 8px 0; + margin: 0 0 28px 0; overflow: hidden; background-color: #1976d2; color: white; @@ -42,11 +42,10 @@ html, body { [data-theme="dark"] .thinking-section { background-color: #1565c0; } - .thinking-header { display: flex; align-items: center; - justify-content: space-between; + justify-content: space-between; /* Ensures left content stays left, timestamp stays right */ padding: 12px 16px; cursor: pointer; user-select: none; @@ -68,13 +67,17 @@ html, body { [data-theme="dark"] .thinking-header:hover { background-color: rgba(0, 0, 0, 0.3); } +.markdown-body { + padding-top: ; +} .thinking-header-left { display: flex; align-items: center; - gap: 8px; + gap: 8px; /* Controls spacing between chevron and "Reasoning" */ } + .thinking-header .indicator { width: 20px; height: 20px; @@ -87,8 +90,7 @@ html, body { } .thinking-header .timestamp { - font-size: 0.85rem; - color: rgba(255, 255, 255, 0.7); + margin-left: auto; /* Pushes it to the right */ } .thinking-content { diff --git a/electron-file-search/vite.config.ts b/electron-file-search/vite.config.ts index 50efac4..df3809a 100644 --- a/electron-file-search/vite.config.ts +++ b/electron-file-search/vite.config.ts @@ -5,17 +5,23 @@ import path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], - base: process.env.ELECTRON_VITE_DEV_SERVER_URL ? '/' : './', + base: './', build: { outDir: 'dist', emptyOutDir: true, target: 'esnext', rollupOptions: { - external: ['http', 'https', 'path', 'fs', 'electron'] + external: ['electron', 'electron-store', ...Object.keys(require('./package.json').dependencies)], + output: { + format: 'es', + entryFileNames: '[name].js', + chunkFileNames: '[name].js', + assetFileNames: '[name][extname]' + } }, - assetsDir: '.', - minify: true, - sourcemap: false + assetsInlineLimit: 0, + minify: 'esbuild', + sourcemap: true }, resolve: { alias: {