From b78cb8eac2a043ebae2b81629139662d44137556 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 11 Sep 2025 18:41:16 -0400 Subject: [PATCH] Now with basic AI summary for Journal Entries --- package-lock.json | 26 +- package.json | 3 +- src/lib/ae_journals/ae_journals_stores.ts | 3 + .../ae_comp__journal_entry_obj_id_view.svelte | 254 +++++++++++++++++- 4 files changed, 280 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58b16ee5..5f6acf8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "osit-aether-app-svelte", - "version": "3.0.3", + "version": "3.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "osit-aether-app-svelte", - "version": "3.0.3", + "version": "3.2.0", "dependencies": { "@codemirror/commands": "^6.8.1", "@codemirror/gutter": "^0.19.9", @@ -35,6 +35,7 @@ "html5-qrcode": "^2.3.8", "lucide-svelte": "0.*.0", "marked": "^16.0.0", + "openai": "^5.20.1", "shadcn-svelte": "^1.0.0", "svelte-persisted-store": "^0.12.0" }, @@ -6641,6 +6642,27 @@ "integrity": "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==", "license": "MIT" }, + "node_modules/openai": { + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/openai/-/openai-5.20.1.tgz", + "integrity": "sha512-UndCB0R5V3iB9I98NyF69zNP6YfwU4+Fjk0eW4HhooTm+Awlpm/MGjJTwJsyNV/qkH1NJi0GG+9odwukGTqExQ==", + "license": "Apache-2.0", + "bin": { + "openai": "bin/cli" + }, + "peerDependencies": { + "ws": "^8.18.0", + "zod": "^3.23.8" + }, + "peerDependenciesMeta": { + "ws": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", diff --git a/package.json b/package.json index 8b009e3f..707a2d26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "osit-aether-app-svelte", - "version": "3.2.0", + "version": "3.3.0", "description": "One Sky IT's Aether App created with Svelte, SvelteKit, Tailwind CSS, Lucide, Font Awesome, and Skeleton UI. -Scott Idem", "homepage": "https://oneskyit.com/", "private": true, @@ -112,6 +112,7 @@ "html5-qrcode": "^2.3.8", "lucide-svelte": "0.*.0", "marked": "^16.0.0", + "openai": "^5.20.1", "shadcn-svelte": "^1.0.0", "svelte-persisted-store": "^0.12.0" } diff --git a/src/lib/ae_journals/ae_journals_stores.ts b/src/lib/ae_journals/ae_journals_stores.ts index ea8f1388..d652c2ae 100644 --- a/src/lib/ae_journals/ae_journals_stores.ts +++ b/src/lib/ae_journals/ae_journals_stores.ts @@ -51,6 +51,7 @@ let journals_local_data_struct: key_val = { ], }, entry: { + ai__system_prompt: 'Summarize the following journal entry content in a concise manner, focusing on key points and insights.', // 'You are a helpful assistant that helps people find information.', edit: false, edit_kv: {}, }, @@ -94,6 +95,8 @@ let journals_session_data_struct: key_val = { tmp_obj: {}, }, entry: { + show__ai_summary: false, + ai_summary: '', decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted. edit: false, edit_kv: {}, diff --git a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte index a6158533..1c2c47e1 100644 --- a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte +++ b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte @@ -4,15 +4,16 @@ import { goto } from '$app/navigation'; // import { tick } from 'svelte'; import { marked } from 'marked'; +import { Modal } from 'flowbite-svelte'; import { ArrowDown01, ArrowDown10, ArrowDownUp, - BookHeart, BriefcaseBusiness, + BookHeart, Bot, BotMessageSquare, BriefcaseBusiness, CalendarClock, CalendarOff, Clock, CodeXml, Copy, Eye, EyeOff, Flag, FlagOff, FileDown, FileX, Fingerprint, Globe, Group, Hash, History, - LockKeyhole, LockKeyholeOpen, + Loader, LockKeyhole, LockKeyholeOpen, MessageSquareWarning, Menu, Minus, NotebookPen, NotebookText, NotepadTextDashed, Pencil, PenLine, Plus, @@ -26,6 +27,26 @@ import { } from '@lucide/svelte'; +// Import OpenAI, but use it with local LLM server (ollama) +import OpenAI from "openai"; +// import { Configuration, OpenAIApi } from 'openai'; + +let llm_api_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.zc2u8vVH1yNt_mDHF8m9f_ONHfRXHjjC9gb-Y9jYwI0'; + +// api_model = 'DgrZone DeepSeek (8b quick)'; +let llm_api_model = 'dgrzone-deepseek-8b-quick'; +let llm_api_base_url = 'http://localhost:3000/api'; + +// const configuration = new Configuration({ +// apiKey: llm_api_token, +// }); + +// const openai = new OpenAI({ +// apiKey: llm_api_token, +// baseURL: llm_api_base_url, +// }); + + // import E_app_codemirror from '$lib/e_app_codemirror.svelte'; // import E_app_codemirror_v4 from '$lib/e_app_codemirror_v4.svelte'; import E_app_codemirror_v5 from '$lib/e_app_codemirror_v5.svelte'; @@ -1668,6 +1689,98 @@ $effect(() => { {/if} + +
+ + + {#if !$journals_sess?.entry?.show__ai_summary && $journals_sess?.entry?.ai_summary} + + {/if} +
+
@@ -1971,6 +2084,92 @@ tabindex={$ae_loc.edit_mode ? 0 : -1} --> class:bg-yellow-50={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'} class:dark:bg-yellow-950={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'} > + + {#if $journals_sess?.entry?.ai_summary} + + {:else} + + + {/if} + + + {#if (!$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id])} {#if $lq__journal_obj?.cfg_json?.pref_viewer == 'codemirror'} @@ -2473,9 +2672,58 @@ zzzz {/if} - +{#if $journals_sess?.entry?.show__ai_summary && $journals_sess?.entry?.ai_summary} + + + +{/if} + {:else}