From 0136107cca874d128e94bce906be65f1eb929fb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 15:10:16 +0530 Subject: [PATCH 001/158] chore: bump postcss from 8.5.15 to 8.5.19 in /frontend (#29) Bumps [postcss](https://github.com/postcss/postcss) from 8.5.15 to 8.5.19. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/postcss/postcss/compare/8.5.15...8.5.19) --- updated-dependencies: - dependency-name: postcss dependency-version: 8.5.19 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- frontend/package-lock.json | 8 ++++---- frontend/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 3c0ec78..2550d82 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -20,7 +20,7 @@ "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.20", - "postcss": "^8.4.49", + "postcss": "^8.5.19", "tailwindcss": "^4.3.2", "typescript": "^7.0.2", "vite": "^8.0.16" @@ -1789,9 +1789,9 @@ "license": "ISC" }, "node_modules/postcss": { - "version": "8.5.15", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz", - "integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==", + "version": "8.5.19", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.19.tgz", + "integrity": "sha512-Mz8SaolMd8nB+G13WkORcxQKHZ/NE4xXevtkJHVuG+guo9/wYKlIMTKAqGdEmYOXR2ijPjTYNHssizdaVSUNdQ==", "dev": true, "funding": [ { diff --git a/frontend/package.json b/frontend/package.json index 7f52cbf..43e1b02 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -21,7 +21,7 @@ "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.20", - "postcss": "^8.4.49", + "postcss": "^8.5.19", "tailwindcss": "^4.3.2", "typescript": "^7.0.2", "vite": "^8.0.16" From 28dbb3e078f09bdea9f982b26141f103da81a160 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:20:27 +0530 Subject: [PATCH 002/158] Remove LibTorch C++ inference implementation --- train_test/test.cpp | 96 --------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 train_test/test.cpp diff --git a/train_test/test.cpp b/train_test/test.cpp deleted file mode 100644 index 41e25e7..0000000 --- a/train_test/test.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -bool running = true; -void handle_sigint(int) -{ - std::cout << "\n\n[Stopped by user]\n"; - running = false; -} - -std::map build_vocab(const std::string &path) -{ - std::ifstream file(path); - if (!file.is_open()) - { - std::cerr << "[Error] Cannot open: " << path << "\n"; - exit(1); - } - std::string text((std::istreambuf_iterator(file)), std::istreambuf_iterator()); - - std::set char_set(text.begin(), text.end()); - std::vector chars(char_set.begin(), char_set.end()); - std::sort(chars.begin(), chars.end()); - - std::map it; - for (int i = 0; i < (int)chars.size(); i++) - it[i] = chars[i]; - - return it; -} - -int main() -{ - signal(SIGINT, handle_sigint); - - std::string model_path = "../best_model_script.pt"; - std::string cleaned_path = "../cleaned.txt"; - - std::cout << "--- Loading Pre-trained Model ---\n"; - torch::jit::script::Module model; - try - { - model = torch::jit::load(model_path, torch::kCPU); - } - catch (const c10::Error &e) - { - std::cerr << "[Error] Could not load model: " << e.what() << "\n"; - return 1; - } - model.eval(); - - auto it = build_vocab(cleaned_path); - std::cout << "[INFO] Vocab size : " << it.size() << "\n"; - std::cout << "[INFO] Device : CPU\n"; - std::cout << "Model loaded. Generating text (Ctrl+C to stop)...\n\n"; - std::cout << std::string(50, '-') << "\n"; - - const int block_size = 128; - auto context = torch::zeros({1, 1}, torch::kLong); - - torch::NoGradGuard no_grad; - - while (running) - { - auto idx_cond = context; - if (context.size(1) > block_size) - idx_cond = context.slice(1, context.size(1) - block_size); - - std::vector inputs = {idx_cond}; - auto output = model.forward(inputs).toTuple(); - auto logits = output->elements()[0].toTensor(); - - logits = logits.select(1, logits.size(1) - 1); - auto probs = torch::softmax(logits, -1); - auto idx_next = torch::multinomial(probs, 1); - - context = torch::cat({context, idx_next}, 1); - if (context.size(1) > block_size) - context = context.slice(1, context.size(1) - block_size); - - int token = idx_next[0][0].item(); - if (it.count(token)) - std::cout << it[token] << std::flush; - else - std::cout << '?' << std::flush; - } - - return 0; -} \ No newline at end of file From b03d554c9cebc172465ae1df6ae73969de64cf89 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:21:36 +0530 Subject: [PATCH 003/158] Remove LibTorch C++ inference implementation (#30) --- train_test/test.cpp | 96 --------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 train_test/test.cpp diff --git a/train_test/test.cpp b/train_test/test.cpp deleted file mode 100644 index 41e25e7..0000000 --- a/train_test/test.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -bool running = true; -void handle_sigint(int) -{ - std::cout << "\n\n[Stopped by user]\n"; - running = false; -} - -std::map build_vocab(const std::string &path) -{ - std::ifstream file(path); - if (!file.is_open()) - { - std::cerr << "[Error] Cannot open: " << path << "\n"; - exit(1); - } - std::string text((std::istreambuf_iterator(file)), std::istreambuf_iterator()); - - std::set char_set(text.begin(), text.end()); - std::vector chars(char_set.begin(), char_set.end()); - std::sort(chars.begin(), chars.end()); - - std::map it; - for (int i = 0; i < (int)chars.size(); i++) - it[i] = chars[i]; - - return it; -} - -int main() -{ - signal(SIGINT, handle_sigint); - - std::string model_path = "../best_model_script.pt"; - std::string cleaned_path = "../cleaned.txt"; - - std::cout << "--- Loading Pre-trained Model ---\n"; - torch::jit::script::Module model; - try - { - model = torch::jit::load(model_path, torch::kCPU); - } - catch (const c10::Error &e) - { - std::cerr << "[Error] Could not load model: " << e.what() << "\n"; - return 1; - } - model.eval(); - - auto it = build_vocab(cleaned_path); - std::cout << "[INFO] Vocab size : " << it.size() << "\n"; - std::cout << "[INFO] Device : CPU\n"; - std::cout << "Model loaded. Generating text (Ctrl+C to stop)...\n\n"; - std::cout << std::string(50, '-') << "\n"; - - const int block_size = 128; - auto context = torch::zeros({1, 1}, torch::kLong); - - torch::NoGradGuard no_grad; - - while (running) - { - auto idx_cond = context; - if (context.size(1) > block_size) - idx_cond = context.slice(1, context.size(1) - block_size); - - std::vector inputs = {idx_cond}; - auto output = model.forward(inputs).toTuple(); - auto logits = output->elements()[0].toTensor(); - - logits = logits.select(1, logits.size(1) - 1); - auto probs = torch::softmax(logits, -1); - auto idx_next = torch::multinomial(probs, 1); - - context = torch::cat({context, idx_next}, 1); - if (context.size(1) > block_size) - context = context.slice(1, context.size(1) - block_size); - - int token = idx_next[0][0].item(); - if (it.count(token)) - std::cout << it[token] << std::flush; - else - std::cout << '?' << std::flush; - } - - return 0; -} \ No newline at end of file From 13342890171dbdf78e2479990d859e1169ed709c Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:24:44 +0530 Subject: [PATCH 004/158] Delete .env.example --- frontend/.env.example | 1 - 1 file changed, 1 deletion(-) delete mode 100644 frontend/.env.example diff --git a/frontend/.env.example b/frontend/.env.example deleted file mode 100644 index 4558365..0000000 --- a/frontend/.env.example +++ /dev/null @@ -1 +0,0 @@ -VITE_API_BASE_URL=http://localhost:3001 From afb931d9a055c51c0492e51ecd292705ad18090f Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:25:14 +0530 Subject: [PATCH 005/158] Delete index.html --- frontend/index.html | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 frontend/index.html diff --git a/frontend/index.html b/frontend/index.html deleted file mode 100644 index c694ea2..0000000 --- a/frontend/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - Quadtrix.cpp Chat - - -
- - - From 145f7894851560bafff0a765e068778dfd0dad0d Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:25:32 +0530 Subject: [PATCH 006/158] Delete manifest.webmanifest --- frontend/manifest.webmanifest | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 frontend/manifest.webmanifest diff --git a/frontend/manifest.webmanifest b/frontend/manifest.webmanifest deleted file mode 100644 index 882922b..0000000 --- a/frontend/manifest.webmanifest +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "Quadtrix.cpp Chat", - "short_name": "Quadtrix", - "description": "Installable local chat interface for Quadtrix C++ and PyTorch model backends.", - "start_url": "/", - "scope": "/", - "display": "standalone", - "background_color": "#0a0a0a", - "theme_color": "#0a0a0a", - "orientation": "any", - "categories": ["developer", "productivity", "utilities"], - "icons": [ - { - "src": "/icon.svg", - "sizes": "any", - "type": "image/svg+xml", - "purpose": "any maskable" - } - ] -} From 9a3bc9dbada8c527f7b280ce02f30419adc7ed54 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:25:39 +0530 Subject: [PATCH 007/158] Delete postcss.config.js --- frontend/postcss.config.js | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 frontend/postcss.config.js diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js deleted file mode 100644 index 2aa7205..0000000 --- a/frontend/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; From 9b3e2b7cc14916a287643bfe6c715173bdc9c2ce Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:25:46 +0530 Subject: [PATCH 008/158] Delete icon.svg --- frontend/public/icon.svg | 53 ---------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 frontend/public/icon.svg diff --git a/frontend/public/icon.svg b/frontend/public/icon.svg deleted file mode 100644 index fe615d0..0000000 --- a/frontend/public/icon.svg +++ /dev/null @@ -1,53 +0,0 @@ - - LLM logo icon - A dark rounded-square icon with a smooth rainbow-gradient LLM wordmark, inspired by Apple TV aesthetic - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LLM - - - - - - - \ No newline at end of file From 5d9a47c0799442f138c6c5d1590651561735cd19 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:28:34 +0530 Subject: [PATCH 009/158] Delete manifest.webmanifest --- frontend/public/manifest.webmanifest | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 frontend/public/manifest.webmanifest diff --git a/frontend/public/manifest.webmanifest b/frontend/public/manifest.webmanifest deleted file mode 100644 index 882922b..0000000 --- a/frontend/public/manifest.webmanifest +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "Quadtrix.cpp Chat", - "short_name": "Quadtrix", - "description": "Installable local chat interface for Quadtrix C++ and PyTorch model backends.", - "start_url": "/", - "scope": "/", - "display": "standalone", - "background_color": "#0a0a0a", - "theme_color": "#0a0a0a", - "orientation": "any", - "categories": ["developer", "productivity", "utilities"], - "icons": [ - { - "src": "/icon.svg", - "sizes": "any", - "type": "image/svg+xml", - "purpose": "any maskable" - } - ] -} From 616264ec4adcdd8d500e2e536c192f6dc69a9a14 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:28:44 +0530 Subject: [PATCH 010/158] Delete sw.js --- frontend/public/sw.js | 52 ------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 frontend/public/sw.js diff --git a/frontend/public/sw.js b/frontend/public/sw.js deleted file mode 100644 index 4f5d599..0000000 --- a/frontend/public/sw.js +++ /dev/null @@ -1,52 +0,0 @@ -const CACHE_NAME = 'quadtrix-chat-v1'; -const APP_SHELL = ['/', '/manifest.webmanifest', '/icon.svg']; - -self.addEventListener('install', (event) => { - event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(APP_SHELL))); - self.skipWaiting(); -}); - -self.addEventListener('activate', (event) => { - event.waitUntil( - caches.keys().then((keys) => - Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))) - ) - ); - self.clients.claim(); -}); - -self.addEventListener('fetch', (event) => { - if (event.request.method !== 'GET') { - return; - } - - const url = new URL(event.request.url); - - const isApiRequest = - url.pathname.startsWith('/api/') || - url.pathname === '/generate' || - url.pathname === '/health' || - url.pathname === '/status'; - - if (isApiRequest) { - return; - } - - event.respondWith( - caches.match(event.request).then((cached) => { - if (cached) { - return cached; - } - return fetch(event.request) - .then((response) => { - if (!response || response.status !== 200 || response.type === 'opaque') { - return response; - } - const copy = response.clone(); - caches.open(CACHE_NAME).then((cache) => cache.put(event.request, copy)); - return response; - }) - .catch(() => caches.match('/')); - }) - ); -}); From f8618806a14c42a49b44cc97f32ea36c8f33a53c Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:28:49 +0530 Subject: [PATCH 011/158] Delete chat.ts --- frontend/src/api/chat.ts | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 frontend/src/api/chat.ts diff --git a/frontend/src/api/chat.ts b/frontend/src/api/chat.ts deleted file mode 100644 index 70ea5e0..0000000 --- a/frontend/src/api/chat.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { useMutation, useQueryClient } from "@tanstack/react-query"; - -import { apiFetch } from "./client"; -import type { ChatRequest, ChatResponse } from "../types"; - -export function useSendMessage() { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: async (payload: ChatRequest): Promise => { - try { - return await apiFetch("/api/chat", { - method: "POST", - body: JSON.stringify(payload), - }); - } catch (error) { - throw error; - } - }, - onSuccess: async (response) => { - await queryClient.invalidateQueries({ queryKey: ["sessions"] }); - await queryClient.invalidateQueries({ queryKey: ["messages", response.session_id] }); - }, - }); -} From f67dcb406fac95f042c05ebdaaad8573f5b0c53a Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:28:56 +0530 Subject: [PATCH 012/158] Delete client.ts --- frontend/src/api/client.ts | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 frontend/src/api/client.ts diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts deleted file mode 100644 index 3299818..0000000 --- a/frontend/src/api/client.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { useSettingsStore } from "../store/settingsStore"; -import type { ApiError } from "../types"; - -export class ApiClientError extends Error { - apiError: ApiError; - - constructor(apiError: ApiError) { - super(apiError.message); - this.apiError = apiError; - } -} - -export async function apiFetch(path: string, init?: RequestInit): Promise { - const baseUrl = useSettingsStore.getState().apiBaseUrl.replace(/\/$/, ""); - const headers = new Headers(init?.headers); - headers.set("Content-Type", "application/json"); - try { - const response = await fetch(`${baseUrl}${path}`, { - ...init, - headers, - }); - if (!response.ok) { - const fallback: ApiError = { error: "request_failed", message: response.statusText, code: response.status }; - const error = (await response.json().catch(() => fallback)) as ApiError; - throw new ApiClientError(error); - } - if (response.status === 204) { - return undefined as T; - } - return (await response.json()) as T; - } catch (error) { - if (error instanceof ApiClientError) { - throw error; - } - throw new ApiClientError({ error: "network_error", message: "Could not reach the API server", code: 0 }); - } -} From 21f9fb43f01b802c06dc3e2a298ed56605c587b8 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:00 +0530 Subject: [PATCH 013/158] Delete health.ts --- frontend/src/api/health.ts | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 frontend/src/api/health.ts diff --git a/frontend/src/api/health.ts b/frontend/src/api/health.ts deleted file mode 100644 index cb2da72..0000000 --- a/frontend/src/api/health.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; - -import { apiFetch } from "./client"; -import type { HealthResponse, ModelStats } from "../types"; - -export function useHealth() { - return useQuery({ - queryKey: ["health"], - queryFn: async (): Promise => { - try { - return await apiFetch("/api/health"); - } catch (error) { - throw error; - } - }, - refetchInterval: 30000, - retry: 1, - }); -} - -export function useStats() { - return useQuery({ - queryKey: ["stats"], - queryFn: async (): Promise => { - try { - return await apiFetch("/api/stats"); - } catch (error) { - throw error; - } - }, - refetchInterval: 30000, - retry: 1, - }); -} From f61e54e1ff9f287d8acc09f209b24584b3e6e0b9 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:07 +0530 Subject: [PATCH 014/158] Delete sessions.ts --- frontend/src/api/sessions.ts | 66 ------------------------------------ 1 file changed, 66 deletions(-) delete mode 100644 frontend/src/api/sessions.ts diff --git a/frontend/src/api/sessions.ts b/frontend/src/api/sessions.ts deleted file mode 100644 index 967089c..0000000 --- a/frontend/src/api/sessions.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; - -import { apiFetch } from "./client"; -import type { Message, Session } from "../types"; - -export function useSessions() { - return useQuery({ - queryKey: ["sessions"], - queryFn: async (): Promise => { - try { - return await apiFetch("/api/sessions"); - } catch (error) { - throw error; - } - }, - }); -} - -export function useCreateSession() { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: async (title?: string): Promise => { - try { - return await apiFetch("/api/sessions", { - method: "POST", - body: JSON.stringify({ title }), - }); - } catch (error) { - throw error; - } - }, - onSuccess: async () => { - await queryClient.invalidateQueries({ queryKey: ["sessions"] }); - }, - }); -} - -export function useDeleteSession() { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: async (sessionId: string): Promise => { - try { - await apiFetch(`/api/sessions/${sessionId}`, { method: "DELETE" }); - } catch (error) { - throw error; - } - }, - onSuccess: async () => { - await queryClient.invalidateQueries({ queryKey: ["sessions"] }); - }, - }); -} - -export function useSessionMessages(sessionId: string | null) { - return useQuery({ - queryKey: ["messages", sessionId], - enabled: Boolean(sessionId), - queryFn: async (): Promise => { - try { - return await apiFetch(`/api/sessions/${sessionId}/messages`); - } catch (error) { - throw error; - } - }, - }); -} From d78725d9ab965076477e2bc9cb3c00648adb5149 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:28 +0530 Subject: [PATCH 015/158] Delete App.tsx --- frontend/src/App.tsx | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 frontend/src/App.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx deleted file mode 100644 index 6141dcf..0000000 --- a/frontend/src/App.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { useCallback } from "react"; - -import { ChatView } from "./components/chat/ChatView"; -import { AppLayout } from "./components/layout/AppLayout"; -import { useKeyboardShortcut } from "./hooks/useKeyboardShortcut"; -import { useCreateSession } from "./api/sessions"; -import { useSessionStore } from "./store/sessionStore"; -import { useSettingsStore } from "./store/settingsStore"; - -export default function App() { - const clearMessages = useSessionStore((state) => state.clearMessages); - const setActiveSession = useSessionStore((state) => state.setActiveSession); - const setMessages = useSessionStore((state) => state.setMessages); - const setSettingsOpen = useSettingsStore((state) => state.setSettingsOpen); - const createSession = useCreateSession(); - - const newConversation = useCallback(() => { - createSession.mutate(undefined, { - onSuccess: (session) => { - setActiveSession(session.id); - setMessages([]); - }, - }); - }, [createSession, setActiveSession, setMessages]); - - const openSettings = useCallback(() => setSettingsOpen(true), [setSettingsOpen]); - const closeSettings = useCallback(() => setSettingsOpen(false), [setSettingsOpen]); - - useKeyboardShortcut(["ctrl", "l"], clearMessages); - useKeyboardShortcut(["ctrl", "n"], newConversation); - useKeyboardShortcut(["ctrl", ","], openSettings); - useKeyboardShortcut(["escape"], closeSettings); - - return ( - - - - ); -} From 9a37031a1a2186073b10305c4d4fa694dcf7cf8c Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:32 +0530 Subject: [PATCH 016/158] Delete ChatView.tsx --- frontend/src/components/chat/ChatView.tsx | 107 ---------------------- 1 file changed, 107 deletions(-) delete mode 100644 frontend/src/components/chat/ChatView.tsx diff --git a/frontend/src/components/chat/ChatView.tsx b/frontend/src/components/chat/ChatView.tsx deleted file mode 100644 index 68c29eb..0000000 --- a/frontend/src/components/chat/ChatView.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import { useEffect, useState } from "react"; - -import { ApiClientError } from "../../api/client"; -import { useSendMessage } from "../../api/chat"; -import { useSessionMessages } from "../../api/sessions"; -import { useHealth } from "../../api/health"; -import { useSessionStore } from "../../store/sessionStore"; -import { useSettingsStore } from "../../store/settingsStore"; -import type { Message } from "../../types"; -import { EmptyState } from "./EmptyState"; -import { MessageList } from "./MessageList"; -import { InputBar } from "../input/InputBar"; - -export function ChatView() { - const [draft, setDraft] = useState(""); - const activeSessionId = useSessionStore((state) => state.activeSessionId); - const messages = useSessionStore((state) => state.messages); - const setActiveSession = useSessionStore((state) => state.setActiveSession); - const setMessages = useSessionStore((state) => state.setMessages); - const addMessage = useSessionStore((state) => state.addMessage); - const replaceMessage = useSessionStore((state) => state.replaceMessage); - const maxTokens = useSettingsStore((state) => state.maxTokens); - const temperature = useSettingsStore((state) => state.temperature); - const modelBackend = useSettingsStore((state) => state.modelBackend); - const sendMessage = useSendMessage(); - const { data: health } = useHealth(); - const { data: fetchedMessages } = useSessionMessages(activeSessionId); - const online = modelBackend === "cpp" ? health?.cpp_server === "ok" : health?.torch_model === "ok"; - - useEffect(() => { - if (fetchedMessages) { - setMessages(fetchedMessages); - } - }, [fetchedMessages, setMessages]); - - const now = (): string => new Date().toISOString(); - - const handleSend = (prompt: string): void => { - const sessionId = activeSessionId ?? crypto.randomUUID(); - setActiveSession(sessionId); - const userMessage: Message = { - id: `local-${crypto.randomUUID()}`, - session_id: sessionId, - role: "user", - text: prompt, - chars: 0, - seconds: 0, - created_at: now(), - }; - const pendingId = `pending-${crypto.randomUUID()}`; - const pendingMessage: Message = { - id: pendingId, - session_id: sessionId, - role: "assistant", - text: "", - chars: 0, - seconds: 0, - created_at: now(), - pending: true, - }; - addMessage(userMessage); - addMessage(pendingMessage); - sendMessage.mutate( - { session_id: sessionId, prompt, max_tokens: maxTokens, temperature, stream: false, model_backend: modelBackend }, - { - onSuccess: (response) => { - setActiveSession(response.session_id); - replaceMessage(pendingId, { - id: response.id, - session_id: response.session_id, - role: "assistant", - text: response.text, - prompt: response.prompt, - chars: response.chars, - seconds: response.seconds, - created_at: response.created_at, - }); - }, - onError: (error) => { - const message = - error instanceof ApiClientError - ? error.apiError.message - : "Could not reach the selected model. Check the C++ server or engine checkpoint."; - replaceMessage(pendingId, { - ...pendingMessage, - text: message, - pending: false, - error: "model_unavailable", - }); - }, - }, - ); - }; - - return ( -
- {messages.length === 0 ? : } - -
- ); -} From 165274ac0c81c585f070a9eff910e4201227e616 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:37 +0530 Subject: [PATCH 017/158] Delete EmptyState.tsx --- frontend/src/components/chat/EmptyState.tsx | 97 --------------------- 1 file changed, 97 deletions(-) delete mode 100644 frontend/src/components/chat/EmptyState.tsx diff --git a/frontend/src/components/chat/EmptyState.tsx b/frontend/src/components/chat/EmptyState.tsx deleted file mode 100644 index abf94ec..0000000 --- a/frontend/src/components/chat/EmptyState.tsx +++ /dev/null @@ -1,97 +0,0 @@ -export function EmptyState() { - return ( -
-
- {/* Icon */} -
- - - - -
- -
-

- Quadtrix.cpp -

-

- Local char-level language model. Start a conversation below. -

-
- - {/* Hint chips */} -
- {["Fast local inference", "C++ & PyTorch backends", "No cloud required"].map((chip) => ( - - {chip} - - ))} -
-
-
- ); -} From ba5fa5e2cf927ee0054c7c0db3927b64b29454d1 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:44 +0530 Subject: [PATCH 018/158] Delete MessageAvatar.tsx --- .../src/components/chat/MessageAvatar.tsx | 53 ------------------- 1 file changed, 53 deletions(-) delete mode 100644 frontend/src/components/chat/MessageAvatar.tsx diff --git a/frontend/src/components/chat/MessageAvatar.tsx b/frontend/src/components/chat/MessageAvatar.tsx deleted file mode 100644 index c606c9d..0000000 --- a/frontend/src/components/chat/MessageAvatar.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import type { Role } from "../../types"; - -interface MessageAvatarProps { - role: Role; -} - -export function MessageAvatar({ role }: MessageAvatarProps) { - const isUser = role === "user"; - - if (isUser) { - return ( -
- U -
- ); - } - - return ( -
- Q -
- ); -} From 7d046d67bce7c0736620c527c1257254bef1d54d Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:29:48 +0530 Subject: [PATCH 019/158] Delete MessageList.tsx --- frontend/src/components/chat/MessageList.tsx | 33 -------------------- 1 file changed, 33 deletions(-) delete mode 100644 frontend/src/components/chat/MessageList.tsx diff --git a/frontend/src/components/chat/MessageList.tsx b/frontend/src/components/chat/MessageList.tsx deleted file mode 100644 index 5de6e62..0000000 --- a/frontend/src/components/chat/MessageList.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useRef } from "react"; -import type { Message } from "../../types"; -import { useAutoScroll } from "../../hooks/useAutoScroll"; -import { MessageRow } from "./MessageRow"; - -interface MessageListProps { - messages: Message[]; -} - -export function MessageList({ messages }: MessageListProps) { - const bottomRef = useRef(null); - useAutoScroll(bottomRef, messages); - - return ( -
-
- {messages.map((message) => ( - - ))} -
-
-
- ); -} From 1a01782b7d76819b179be3e6d69f5daf96548365 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:30:01 +0530 Subject: [PATCH 020/158] Delete torch_bridge.h --- llm.cpp/include/torch_bridge.h | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 llm.cpp/include/torch_bridge.h diff --git a/llm.cpp/include/torch_bridge.h b/llm.cpp/include/torch_bridge.h deleted file mode 100644 index 7e5e784..0000000 --- a/llm.cpp/include/torch_bridge.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "tensor.h" -#include -#include -#include -#include - -inline torch::Tensor to_torch_tensor(const Tensor &src) -{ - if (src.shape.empty() || src.shape.size() > 3) - throw std::invalid_argument("Tensor rank must be 1, 2, or 3"); - - std::vector sizes(src.shape.begin(), src.shape.end()); - auto tensor = torch::from_blob( - const_cast(src.data.data()), - torch::IntArrayRef(sizes), - torch::TensorOptions().dtype(torch::kFloat32)) - .clone(); - return tensor; -} - -inline Tensor from_torch_tensor(const torch::Tensor &src) -{ - auto cpu = src.contiguous().to(torch::kCPU).to(torch::kFloat32); - std::vector shape; - shape.reserve(cpu.dim()); - for (int64_t i = 0; i < cpu.dim(); ++i) - shape.push_back(static_cast(cpu.size(i))); - - Tensor out(shape); - std::memcpy(out.data.data(), cpu.data_ptr(), out.numel() * sizeof(float)); - return out; -} From 1e847bbfe9f49111b1ad8e05e84fa22232b4dfee Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:30:12 +0530 Subject: [PATCH 021/158] Delete tensor.h --- llm.cpp/include/tensor.h | 567 --------------------------------------- 1 file changed, 567 deletions(-) delete mode 100644 llm.cpp/include/tensor.h diff --git a/llm.cpp/include/tensor.h b/llm.cpp/include/tensor.h deleted file mode 100644 index c3526b6..0000000 --- a/llm.cpp/include/tensor.h +++ /dev/null @@ -1,567 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _OPENMP -#include -#endif - -#ifdef __AVX__ -#include -#endif - -#ifdef __SSE__ -#include -#endif - -struct Tensor -{ - std::vector shape; - std::vector data; - - Tensor() = default; - - Tensor(std::vector sh, float fill = 0.0f) : shape(std::move(sh)) - { - int total = 1; - for (int d : shape) - total *= d; - data.reserve(total); - data.assign(total, fill); - } - - Tensor(const Tensor &) = default; - Tensor(Tensor &&) noexcept = default; - Tensor &operator=(const Tensor &) = default; - Tensor &operator=(Tensor &&) noexcept = default; - - int numel() const - { - int n = 1; - for (int d : shape) - n *= d; - return n; - } - - int ndim() const { return (int)shape.size(); } - - float &at(int i) { return data[i]; } - float at(int i) const { return data[i]; } - - float &at(int r, int c) { return data[r * shape[1] + c]; } - float at(int r, int c) const { return data[r * shape[1] + c]; } - - float &at(int b, int r, int c) { return data[b * shape[1] * shape[2] + r * shape[2] + c]; } - float at(int b, int r, int c) const { return data[b * shape[1] * shape[2] + r * shape[2] + c]; } - - static Tensor zeros(std::vector sh) { return Tensor(sh, 0.0f); } - static Tensor ones(std::vector sh) { return Tensor(sh, 1.0f); } - - static Tensor randn(std::vector sh, float mean, float std, std::mt19937 &rng) - { - std::normal_distribution dist(mean, std); - Tensor t(sh); - for (auto &v : t.data) - v = dist(rng); - return t; - } - - void fill(float v) { std::fill(data.begin(), data.end(), v); } - - void print_shape(const std::string &name = "") const - { - if (!name.empty()) - std::cout << name << ": "; - std::cout << "["; - for (int i = 0; i < (int)shape.size(); ++i) - { - std::cout << shape[i]; - if (i + 1 < (int)shape.size()) - std::cout << ", "; - } - std::cout << "]" << std::endl; - } -}; - -inline Tensor add(const Tensor &a, const Tensor &b) -{ - assert(a.data.size() == b.data.size()); - Tensor c(a.shape); - size_t n = a.data.size(); - -#ifdef __AVX__ - size_t i = 0; - size_t vec_end = n & ~7ULL; - for (; i < vec_end; i += 8) - { - __m256 va = _mm256_loadu_ps(&a.data[i]); - __m256 vb = _mm256_loadu_ps(&b.data[i]); - __m256 vc = _mm256_add_ps(va, vb); - _mm256_storeu_ps(&c.data[i], vc); - } - for (; i < n; ++i) - c.data[i] = a.data[i] + b.data[i]; -#elif defined(__SSE__) - size_t i = 0; - size_t vec_end = n & ~3ULL; - for (; i < vec_end; i += 4) - { - __m128 va = _mm_loadu_ps(&a.data[i]); - __m128 vb = _mm_loadu_ps(&b.data[i]); - __m128 vc = _mm_add_ps(va, vb); - _mm_storeu_ps(&c.data[i], vc); - } - for (; i < n; ++i) - c.data[i] = a.data[i] + b.data[i]; -#else - for (size_t i = 0; i < n; ++i) - c.data[i] = a.data[i] + b.data[i]; -#endif - return c; -} - -inline void add_inplace(Tensor &a, const Tensor &b) -{ - assert(a.data.size() == b.data.size()); - size_t n = a.data.size(); - -#ifdef __AVX__ - size_t i = 0; - size_t vec_end = n & ~7ULL; - for (; i < vec_end; i += 8) - { - __m256 va = _mm256_loadu_ps(&a.data[i]); - __m256 vb = _mm256_loadu_ps(&b.data[i]); - __m256 vc = _mm256_add_ps(va, vb); - _mm256_storeu_ps(&a.data[i], vc); - } - for (; i < n; ++i) - a.data[i] += b.data[i]; -#elif defined(__SSE__) - size_t i = 0; - size_t vec_end = n & ~3ULL; - for (; i < vec_end; i += 4) - { - __m128 va = _mm_loadu_ps(&a.data[i]); - __m128 vb = _mm_loadu_ps(&b.data[i]); - __m128 vc = _mm_add_ps(va, vb); - _mm_storeu_ps(&a.data[i], vc); - } - for (; i < n; ++i) - a.data[i] += b.data[i]; -#else - for (size_t i = 0; i < n; ++i) - a.data[i] += b.data[i]; -#endif -} - -inline Tensor scale(const Tensor &a, float s) -{ - Tensor c(a.shape); - size_t n = a.data.size(); - -#ifdef __AVX__ - size_t i = 0; - size_t vec_end = n & ~7ULL; - __m256 vs = _mm256_set1_ps(s); - for (; i < vec_end; i += 8) - { - __m256 va = _mm256_loadu_ps(&a.data[i]); - __m256 vc = _mm256_mul_ps(va, vs); - _mm256_storeu_ps(&c.data[i], vc); - } - for (; i < n; ++i) - c.data[i] = a.data[i] * s; -#elif defined(__SSE__) - size_t i = 0; - size_t vec_end = n & ~3ULL; - __m128 vs = _mm_set1_ps(s); - for (; i < vec_end; i += 4) - { - __m128 va = _mm_loadu_ps(&a.data[i]); - __m128 vc = _mm_mul_ps(va, vs); - _mm_storeu_ps(&c.data[i], vc); - } - for (; i < n; ++i) - c.data[i] = a.data[i] * s; -#else - for (size_t i = 0; i < n; ++i) - c.data[i] = a.data[i] * s; -#endif - return c; -} - -inline void scale_inplace(Tensor &a, float s) -{ - size_t n = a.data.size(); - -#ifdef __AVX__ - size_t i = 0; - size_t vec_end = n & ~7ULL; - __m256 vs = _mm256_set1_ps(s); - for (; i < vec_end; i += 8) - { - __m256 va = _mm256_loadu_ps(&a.data[i]); - __m256 vc = _mm256_mul_ps(va, vs); - _mm256_storeu_ps(&a.data[i], vc); - } - for (; i < n; ++i) - a.data[i] *= s; -#elif defined(__SSE__) - size_t i = 0; - size_t vec_end = n & ~3ULL; - __m128 vs = _mm_set1_ps(s); - for (; i < vec_end; i += 4) - { - __m128 va = _mm_loadu_ps(&a.data[i]); - __m128 vc = _mm_mul_ps(va, vs); - _mm_storeu_ps(&a.data[i], vc); - } - for (; i < n; ++i) - a.data[i] *= s; -#else - for (auto &v : a.data) - v *= s; -#endif -} - -inline Tensor relu(const Tensor &a) -{ - Tensor c(a.shape); - size_t n = a.data.size(); - -#ifdef __AVX__ - size_t i = 0; - size_t vec_end = n & ~7ULL; - __m256 zero = _mm256_setzero_ps(); - for (; i < vec_end; i += 8) - { - __m256 va = _mm256_loadu_ps(&a.data[i]); - __m256 vc = _mm256_max_ps(va, zero); - _mm256_storeu_ps(&c.data[i], vc); - } - for (; i < n; ++i) - c.data[i] = std::max(0.0f, a.data[i]); -#elif defined(__SSE__) - size_t i = 0; - size_t vec_end = n & ~3ULL; - __m128 zero = _mm_setzero_ps(); - for (; i < vec_end; i += 4) - { - __m128 va = _mm_loadu_ps(&a.data[i]); - __m128 vc = _mm_max_ps(va, zero); - _mm_storeu_ps(&c.data[i], vc); - } - for (; i < n; ++i) - c.data[i] = std::max(0.0f, a.data[i]); -#else - for (size_t i = 0; i < n; ++i) - c.data[i] = std::max(0.0f, a.data[i]); -#endif - return c; -} - -inline void relu_inplace(Tensor &a) -{ - size_t n = a.data.size(); - -#ifdef __AVX__ - size_t i = 0; - size_t vec_end = n & ~7ULL; - __m256 zero = _mm256_setzero_ps(); - for (; i < vec_end; i += 8) - { - __m256 va = _mm256_loadu_ps(&a.data[i]); - __m256 vc = _mm256_max_ps(va, zero); - _mm256_storeu_ps(&a.data[i], vc); - } - for (; i < n; ++i) - a.data[i] = std::max(0.0f, a.data[i]); -#elif defined(__SSE__) - size_t i = 0; - size_t vec_end = n & ~3ULL; - __m128 zero = _mm_setzero_ps(); - for (; i < vec_end; i += 4) - { - __m128 va = _mm_loadu_ps(&a.data[i]); - __m128 vc = _mm_max_ps(va, zero); - _mm_storeu_ps(&a.data[i], vc); - } - for (; i < n; ++i) - a.data[i] = std::max(0.0f, a.data[i]); -#else - for (auto &v : a.data) - v = std::max(0.0f, v); -#endif -} - -inline Tensor softmax3d(const Tensor &a) -{ - int B = a.shape[0], T = a.shape[1], C = a.shape[2]; - Tensor out(a.shape); - -#ifdef _OPENMP -#pragma omp parallel for collapse(2) if (B * T > 64) -#endif - for (int b = 0; b < B; ++b) - { - for (int t = 0; t < T; ++t) - { - float maxv = -1e30f; - for (int c = 0; c < C; ++c) - maxv = std::max(maxv, a.at(b, t, c)); - - float sumv = 0.0f; - for (int c = 0; c < C; ++c) - { - float e = std::exp(a.at(b, t, c) - maxv); - out.at(b, t, c) = e; - sumv += e; - } - - float inv_sum = 1.0f / sumv; - for (int c = 0; c < C; ++c) - out.at(b, t, c) *= inv_sum; - } - } - return out; -} - -inline Tensor softmax2d(const Tensor &a) -{ - int T = a.shape[0], C = a.shape[1]; - Tensor out(a.shape); - -#ifdef _OPENMP -#pragma omp parallel for if (T > 128) -#endif - for (int t = 0; t < T; ++t) - { - float maxv = -1e30f; - for (int c = 0; c < C; ++c) - maxv = std::max(maxv, a.at(t, c)); - - float sumv = 0.0f; - for (int c = 0; c < C; ++c) - { - float e = std::exp(a.at(t, c) - maxv); - out.at(t, c) = e; - sumv += e; - } - - float inv_sum = 1.0f / sumv; - for (int c = 0; c < C; ++c) - out.at(t, c) *= inv_sum; - } - return out; -} - -inline Tensor layer_norm(const Tensor &x, const Tensor &gamma, const Tensor &beta, float eps = 1e-5f) -{ - int B = x.shape[0], T = x.shape[1], C = x.shape[2]; - Tensor out(x.shape); - -#ifdef _OPENMP -#pragma omp parallel for collapse(2) if (B * T > 64) -#endif - for (int b = 0; b < B; ++b) - { - for (int t = 0; t < T; ++t) - { - float mu = 0.0f; - for (int c = 0; c < C; ++c) - mu += x.at(b, t, c); - mu /= C; - - float var = 0.0f; - for (int c = 0; c < C; ++c) - { - float d = x.at(b, t, c) - mu; - var += d * d; - } - var /= C; - - float inv = 1.0f / std::sqrt(var + eps); - for (int c = 0; c < C; ++c) - out.at(b, t, c) = (x.at(b, t, c) - mu) * inv * gamma.at(c) + beta.at(c); - } - } - return out; -} - -inline Tensor matmul(const Tensor &a, const Tensor &w) -{ - assert(a.ndim() == 3 && w.ndim() == 2); - int B = a.shape[0], T = a.shape[1], D = a.shape[2]; - int E = w.shape[1]; - assert(w.shape[0] == D); - - Tensor out({B, T, E}, 0.0f); - - const int TILE_T = 32; - const int TILE_E = 32; - const int TILE_D = 32; - -#ifdef _OPENMP -#pragma omp parallel for collapse(2) if (B * T * E * D > 100000) -#endif - for (int b = 0; b < B; ++b) - { - for (int t0 = 0; t0 < T; t0 += TILE_T) - { - int t_end = std::min(t0 + TILE_T, T); - for (int e0 = 0; e0 < E; e0 += TILE_E) - { - int e_end = std::min(e0 + TILE_E, E); - for (int d0 = 0; d0 < D; d0 += TILE_D) - { - int d_end = std::min(d0 + TILE_D, D); - for (int t = t0; t < t_end; ++t) - { - for (int e = e0; e < e_end; ++e) - { - float s = out.at(b, t, e); - for (int d = d0; d < d_end; ++d) - s += a.at(b, t, d) * w.at(d, e); - out.at(b, t, e) = s; - } - } - } - } - } - } - return out; -} - -inline Tensor add_bias(const Tensor &x, const Tensor &bias) -{ - assert(x.shape.back() == bias.shape[0]); - Tensor out = x; - int E = bias.shape[0]; - int stride = E; - int n = x.numel() / E; - -#ifdef _OPENMP -#pragma omp parallel for if (n * E > 10000) -#endif - for (int i = 0; i < n; ++i) - { - for (int e = 0; e < E; ++e) - out.data[i * stride + e] += bias.data[e]; - } - return out; -} - -inline Tensor bmm(const Tensor &a, const Tensor &b) -{ - assert(a.ndim() == 3 && b.ndim() == 3); - int B = a.shape[0], T = a.shape[1], D = a.shape[2]; - int T2 = b.shape[2]; - assert(b.shape[0] == B && b.shape[1] == D); - - Tensor out({B, T, T2}, 0.0f); - - const int TILE = 32; - -#ifdef _OPENMP -#pragma omp parallel for if (B * T * T2 * D > 100000) -#endif - for (int bb = 0; bb < B; ++bb) - { - for (int t0 = 0; t0 < T; t0 += TILE) - { - int t_end = std::min(t0 + TILE, T); - for (int t2_0 = 0; t2_0 < T2; t2_0 += TILE) - { - int t2_end = std::min(t2_0 + TILE, T2); - for (int d0 = 0; d0 < D; d0 += TILE) - { - int d_end = std::min(d0 + TILE, D); - for (int t = t0; t < t_end; ++t) - { - for (int t2 = t2_0; t2 < t2_end; ++t2) - { - float s = out.at(bb, t, t2); - for (int d = d0; d < d_end; ++d) - s += a.at(bb, t, d) * b.at(bb, d, t2); - out.at(bb, t, t2) = s; - } - } - } - } - } - } - return out; -} - -inline Tensor transpose23(const Tensor &a) -{ - int B = a.shape[0], T = a.shape[1], D = a.shape[2]; - Tensor out({B, D, T}); - -#ifdef _OPENMP -#pragma omp parallel for collapse(2) if (B * T * D > 10000) -#endif - for (int b = 0; b < B; ++b) - { - for (int d = 0; d < D; ++d) - { - for (int t = 0; t < T; ++t) - out.at(b, d, t) = a.at(b, t, d); - } - } - return out; -} - -inline Tensor cat_last(const std::vector &ts) -{ - int B = ts[0].shape[0], T = ts[0].shape[1]; - int total = 0; - for (auto &t : ts) - total += t.shape[2]; - - Tensor out({B, T, total}, 0.0f); - - int offset = 0; - for (auto &t : ts) - { - int D = t.shape[2]; -#ifdef _OPENMP -#pragma omp parallel for collapse(2) if (B * T * D > 10000) -#endif - for (int b = 0; b < B; ++b) - { - for (int tt = 0; tt < T; ++tt) - { - for (int d = 0; d < D; ++d) - out.at(b, tt, offset + d) = t.at(b, tt, d); - } - } - offset += D; - } - return out; -} - -inline Tensor dropout(const Tensor &x, float p, bool training, std::mt19937 &rng) -{ - if (!training || p == 0.0f) - return x; - - std::bernoulli_distribution dist(1.0f - p); - Tensor out = x; - float scale_v = 1.0f / (1.0f - p); - - for (auto &v : out.data) - v = dist(rng) ? v * scale_v : 0.0f; - - return out; -} \ No newline at end of file From fc81c14124b9f5fefec95b6fd68cd0c8bca723e6 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:30:16 +0530 Subject: [PATCH 022/158] Delete sampler.h --- llm.cpp/include/sampler.h | 50 --------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 llm.cpp/include/sampler.h diff --git a/llm.cpp/include/sampler.h b/llm.cpp/include/sampler.h deleted file mode 100644 index 8bee497..0000000 --- a/llm.cpp/include/sampler.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include "config/config.h" -#include -#include - -// Holds all parameters that control token sampling at inference time. -// Fields can be set from CLI flags or left at config.h defaults. -struct SamplerParams -{ - float rep_penalty; // values above 1.0 reduce repeated tokens - int rep_window; // how many recent tokens to scan for repeats - std::string system_prompt; // text prepended before every user turn in chat - - SamplerParams() - : rep_penalty(DEFAULT_REP_PENALTY), - rep_window(DEFAULT_REP_WINDOW), - system_prompt("") {} -}; - -// Adjust raw logits to make recently seen tokens less likely to appear again. -// Tokens found in the recent context window have their logit reduced: -// positive logits are divided by rep_penalty -// negative logits are multiplied by rep_penalty -// This matches the formula used in llama.cpp repetition penalty. -// Call this on the last time step logits before softmax. -inline void apply_rep_penalty(std::vector &logits, - const std::vector &context, - const SamplerParams ¶ms) -{ - if (params.rep_penalty <= 1.0f || context.empty()) - return; - - int window_start = (int)context.size() - params.rep_window; - if (window_start < 0) - window_start = 0; - - for (int i = window_start; i < (int)context.size(); ++i) - { - int tok = context[i]; - if (tok < 0 || tok >= (int)logits.size()) - continue; - - float &l = logits[tok]; - if (l > 0.0f) - l /= params.rep_penalty; - else - l *= params.rep_penalty; - } -} From e2f8bdb2fbf8af69ebbbb822b3cff797ccd7b2c7 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:32:28 +0530 Subject: [PATCH 023/158] Delete MessageRow.tsx --- frontend/src/components/chat/MessageRow.tsx | 123 -------------------- 1 file changed, 123 deletions(-) delete mode 100644 frontend/src/components/chat/MessageRow.tsx diff --git a/frontend/src/components/chat/MessageRow.tsx b/frontend/src/components/chat/MessageRow.tsx deleted file mode 100644 index 8dd3910..0000000 --- a/frontend/src/components/chat/MessageRow.tsx +++ /dev/null @@ -1,123 +0,0 @@ -import { motion } from "framer-motion"; -import { useState } from "react"; - -import { formatRelativeTime } from "../../utils/time"; -import type { Message } from "../../types"; -import { MessageAvatar } from "./MessageAvatar"; -import { ThinkingIndicator } from "./ThinkingIndicator"; - -interface MessageRowProps { - message: Message; -} - -export function MessageRow({ message }: MessageRowProps) { - const [copied, setCopied] = useState(false); - const isUser = message.role === "user"; - - const copyText = async (): Promise => { - try { - await navigator.clipboard.writeText(message.text); - setCopied(true); - window.setTimeout(() => setCopied(false), 1200); - } catch (error) { - setCopied(false); - } - }; - - return ( - - {!isUser && } - -
- {/* Meta row */} -
- {isUser ? "You" : "Quadtrix"} - {formatRelativeTime(message.created_at)} - {!isUser && !message.pending && ( - - )} -
- - {/* Bubble */} -
- {message.pending ? ( - - ) : ( - {message.text} - )} -
-
- - {isUser && } -
- ); -} From 9560a7afecb0599489cb2b6067e3c2284a676bdd Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:32:33 +0530 Subject: [PATCH 024/158] Delete StarterPrompts.tsx --- .../src/components/chat/StarterPrompts.tsx | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 frontend/src/components/chat/StarterPrompts.tsx diff --git a/frontend/src/components/chat/StarterPrompts.tsx b/frontend/src/components/chat/StarterPrompts.tsx deleted file mode 100644 index fb10a22..0000000 --- a/frontend/src/components/chat/StarterPrompts.tsx +++ /dev/null @@ -1,22 +0,0 @@ -interface StarterPromptsProps { - onSelect: (prompt: string) => void; -} - -const prompts = ["Once upon a time", "Timmy is a", "hi how are you", "The little door opened"]; - -export function StarterPrompts({ onSelect }: StarterPromptsProps) { - return ( -
- {prompts.map((prompt) => ( - - ))} -
- ); -} From efed501b5bf6e79c186d5e908fe519a88a7d7b85 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:32:38 +0530 Subject: [PATCH 025/158] Delete ThinkingIndicator.tsx --- .../src/components/chat/ThinkingIndicator.tsx | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 frontend/src/components/chat/ThinkingIndicator.tsx diff --git a/frontend/src/components/chat/ThinkingIndicator.tsx b/frontend/src/components/chat/ThinkingIndicator.tsx deleted file mode 100644 index 7ec4a6c..0000000 --- a/frontend/src/components/chat/ThinkingIndicator.tsx +++ /dev/null @@ -1,28 +0,0 @@ -export function ThinkingIndicator() { - return ( -
- Generating - - {[0, 120, 240].map((delay) => ( - - ))} - - -
- ); -} From 979ebfb0b1c06e35161828be9383e2fa9c1265a2 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:32:42 +0530 Subject: [PATCH 026/158] Delete CharCounter.tsx --- frontend/src/components/input/CharCounter.tsx | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 frontend/src/components/input/CharCounter.tsx diff --git a/frontend/src/components/input/CharCounter.tsx b/frontend/src/components/input/CharCounter.tsx deleted file mode 100644 index 5ddf619..0000000 --- a/frontend/src/components/input/CharCounter.tsx +++ /dev/null @@ -1,9 +0,0 @@ -interface CharCounterProps { - count: number; - max: number; -} - -export function CharCounter({ count, max }: CharCounterProps) { - const over = count > max; - return {count}/{max}; -} From 8f00f27a7f5c23f8af48a1a22ebe974375e03815 Mon Sep 17 00:00:00 2001 From: Eamon Date: Tue, 14 Jul 2026 15:32:47 +0530 Subject: [PATCH 027/158] Delete InputBar.tsx --- frontend/src/components/input/InputBar.tsx | 158 --------------------- 1 file changed, 158 deletions(-) delete mode 100644 frontend/src/components/input/InputBar.tsx diff --git a/frontend/src/components/input/InputBar.tsx b/frontend/src/components/input/InputBar.tsx deleted file mode 100644 index 6b39639..0000000 --- a/frontend/src/components/input/InputBar.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import { useEffect, useRef, useState } from "react"; -import { CharCounter } from "./CharCounter"; - -interface InputBarProps { - disabled: boolean; - isSending: boolean; - onSend: (prompt: string) => void; - initialValue?: string; - onDraftChange?: (value: string) => void; -} - -export function InputBar({ disabled, isSending, onSend, initialValue = "", onDraftChange }: InputBarProps) { - const [value, setValue] = useState(initialValue); - const ref = useRef(null); - - useEffect(() => { - setValue(initialValue); - }, [initialValue]); - - useEffect(() => { - onDraftChange?.(value); - }, [onDraftChange, value]); - - useEffect(() => { - if (!ref.current) return; - ref.current.style.height = "auto"; - ref.current.style.height = `${Math.min(ref.current.scrollHeight, 120)}px`; - }, [value]); - - const submit = (): void => { - const prompt = value.trim(); - if (!prompt || disabled || isSending) return; - setValue(""); - onSend(prompt); - }; - - return ( -
-
{ - (e.currentTarget as HTMLDivElement).style.borderColor = "var(--border-strong)"; - }} - onBlurCapture={(e) => { - (e.currentTarget as HTMLDivElement).style.borderColor = "var(--border-muted)"; - }} - > -
-