Stabilize Journal Entry view and perform initial comment audit
- Cleaned up redundant imports, legacy script stubs, and dead code. - Removed extensive legacy comments from history and AI summary template sections. - Verified stability of core decryption and data sync logic. - Standardized file structure to serve as a better template for other Aether modules.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
<script lang="ts">
|
||||
// *** Import Svelte specific
|
||||
import { goto } from '$app/navigation';
|
||||
// import { tick } from 'svelte';
|
||||
// let log_lvl: number = 0;
|
||||
|
||||
// *** Import Svelte core and navigation
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
// *** Import secondary libraries
|
||||
import { marked } from 'marked';
|
||||
import { Modal } from 'flowbite-svelte';
|
||||
import {
|
||||
@@ -62,38 +64,13 @@
|
||||
|
||||
import OpenAI from 'openai';
|
||||
|
||||
|
||||
|
||||
// *** Import Aether components and helpers
|
||||
import { wrapSelection, toggleLinePrefix } from '$lib/ae_journals/ae_journals_editor_helpers';
|
||||
|
||||
let llm_api_token =
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.4y5AStXZJAVnWRlgG3lVV0-xKIfMzqdNRuInGwT0ThQ';
|
||||
|
||||
// let llm_api_base_url = 'http://localhost:3000/api';
|
||||
let llm_api_base_url = 'https://ai.dgrzone.com/api';
|
||||
// api_model = 'DgrZone DeepSeek (8b quick)';
|
||||
let llm_api_model = $journals_loc?.llm__api_model; // 'dgrzone-deepseek-8b-quick';
|
||||
|
||||
// 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/app_components/e_app_codemirror_v5.svelte';
|
||||
// import {javascript} from "@codemirror/lang-javascript";
|
||||
// import {markdown} from "@codemirror/lang-markdown";
|
||||
|
||||
// *** Import Aether specific variables and functions
|
||||
// *** Import Aether core logic and stores
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
// import { core_func } from '$lib/ae_core/ae_core_functions';
|
||||
// import { api } from '$lib/api';
|
||||
import {
|
||||
ae_snip,
|
||||
ae_loc,
|
||||
@@ -111,13 +88,15 @@
|
||||
journals_prom
|
||||
} from '$lib/ae_journals/ae_journals_stores';
|
||||
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
|
||||
import Journal_entry_obj_file_li from './ae_comp__journal_entry_obj_file_li.svelte';
|
||||
// import Comp_hosted_files_upload from '$lib/ae_core/ae_comp__hosted_files_upload.svelte';
|
||||
// import Element_manage_hosted_file_li_wrap from '$lib/element_manage_hosted_file_li_all.svelte';
|
||||
import Comp_journal_entry_file_li from './ae_comp__journal_entry_obj_file_li.svelte';
|
||||
import Comp_hosted_files_download_button from '$lib/ae_core/ae_comp__hosted_files_download_button.svelte';
|
||||
import JournalEntry_AITools from './JournalEntry_AITools.svelte';
|
||||
import JournalEntry_Metadata from './JournalEntry_Metadata.svelte';
|
||||
|
||||
// *** Configuration
|
||||
let llm_api_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.4y5AStXZJAVnWRlgG3lVV0-xKIfMzqdNRuInGwT0ThQ';
|
||||
let llm_api_base_url = 'https://ai.dgrzone.com/api';
|
||||
let llm_api_model = $journals_loc?.llm__api_model;
|
||||
|
||||
// *** Props
|
||||
interface Props {
|
||||
log_lvl?: number;
|
||||
lq__journal_obj: any;
|
||||
@@ -132,29 +111,15 @@
|
||||
lq__journal_entry_obj
|
||||
}: Props = $props();
|
||||
|
||||
// *** State
|
||||
let editorView: any = $state();
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`ae_comp__journal_entry_obj_id_view.svelte`,
|
||||
lq__journal_obj,
|
||||
lq__journal_obj_li,
|
||||
lq__journal_entry_obj
|
||||
);
|
||||
}
|
||||
|
||||
let ae_promises: key_val = $state({});
|
||||
// let ae_tmp: key_val = {};
|
||||
// let ae_trigger: any = null;
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
let show_menu: boolean = $state(false);
|
||||
|
||||
// let orig_entry_obj: key_val = $state({});
|
||||
let orig_entry_obj: key_val | null = $state({});
|
||||
let tmp_entry_obj: key_val = $state({});
|
||||
let updated_obj: boolean = $state(true); // Start with true to force population of orig and tmp values.
|
||||
let updated_idb: boolean = $state(true); // Updated in a separate browser session
|
||||
let updated_obj: boolean = $state(true); // Start with true to force population
|
||||
let updated_idb: boolean = $state(true); // Internal session sync flag
|
||||
|
||||
// Idiomatic Svelte 5 change detection
|
||||
let tmp_entry_obj_changed = $derived.by(() => {
|
||||
@@ -170,37 +135,12 @@
|
||||
);
|
||||
});
|
||||
|
||||
// let tmp_entry_obj: key_val = { ...$lq__journal_entry_obj };
|
||||
|
||||
// let tmp_entry_obj = $derived(async () => {
|
||||
// [$lq__journal_entry_obj],
|
||||
// ([$lq__journal_entry_obj]) => {
|
||||
// return $lq__journal_entry_obj;
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
// let codemirror_extensions = [
|
||||
// basicSetup,
|
||||
// keymap.of([indentWithTab]),
|
||||
// javascript()
|
||||
// ]
|
||||
|
||||
// // "Start document"
|
||||
// const codemirror_editorview = new EditorView({
|
||||
// doc: $lq__journal_entry_obj?.content ?? 'yyyy',
|
||||
// parent: document.getElementById('journal_entry_codemirror') as HTMLElement,
|
||||
// extensions: [codemirror_extensions]
|
||||
// })
|
||||
|
||||
let journal_key = $derived(() => {
|
||||
return (
|
||||
$lq__journal_obj?.combined_passcode || $lq__journal_obj?.passcode || 'temp-secret-key'
|
||||
);
|
||||
});
|
||||
// let journal_key = $state($lq__journal_obj?.combined_passcode || $lq__journal_obj?.passcode || 'temp-secret-key');
|
||||
|
||||
let content = ''; // "This is my test content to encrypt and decrypt.";
|
||||
let encrypted_base64_string: string = $state('');
|
||||
let encryption_iv: null | Uint8Array<ArrayBuffer> = $state(null);
|
||||
let decrypted_content: string = $state('');
|
||||
@@ -213,59 +153,28 @@
|
||||
}
|
||||
|
||||
function not_obj(obj) {
|
||||
if (obj == null) {
|
||||
// null or undefined
|
||||
return true;
|
||||
}
|
||||
if (typeof obj !== 'object') {
|
||||
return true;
|
||||
}
|
||||
return Object.keys(obj).length === 0;
|
||||
return !obj || typeof obj !== 'object' || Object.keys(obj).length === 0;
|
||||
}
|
||||
|
||||
$effect(async () => {
|
||||
if ($lq__journal_entry_obj && $lq__journal_entry_obj?.updated_on) {
|
||||
console.log(`TEST: Journal Entry updated datetime changed`, $lq__journal_entry_obj);
|
||||
if (log_lvl) console.log(`Journal Entry updated:`, $lq__journal_entry_obj);
|
||||
|
||||
// updated_obj = false;
|
||||
orig_entry_obj = { ...$lq__journal_entry_obj };
|
||||
tmp_entry_obj = $lq__journal_entry_obj ? { ...$lq__journal_entry_obj } : {};
|
||||
|
||||
// if ($journals_loc?.entry?.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id]) {
|
||||
// if (!tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted) {
|
||||
// console.log('TEST: Decrypting the content...');
|
||||
|
||||
// tmp_entry_obj.content = await ae_util.decrypt_wrapper(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
// tmp_entry_obj.content_md_html = handle_marked(tmp_entry_obj?.content);
|
||||
|
||||
// orig_entry_obj.content = await ae_util.decrypt_wrapper(orig_entry_obj?.content_encrypted, journal_key);
|
||||
// orig_entry_obj.content_md_html = handle_marked(orig_entry_obj?.content);
|
||||
// }
|
||||
// if (!tmp_entry_obj?.history && tmp_entry_obj?.history_encrypted) {
|
||||
// console.log('TEST: Decrypting the history...');
|
||||
|
||||
// tmp_entry_obj.history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
// tmp_entry_obj.history_md_html = handle_marked(tmp_entry_obj?.history);
|
||||
|
||||
// orig_entry_obj.history = await ae_util.decrypt_wrapper(orig_entry_obj?.history_encrypted, journal_key);
|
||||
// orig_entry_obj.history_md_html = handle_marked(orig_entry_obj?.history);
|
||||
// }
|
||||
// }
|
||||
|
||||
tmp_entry_obj_changed = false;
|
||||
// updated_obj = false;
|
||||
updated_idb = false;
|
||||
} else if (updated_obj && (await $lq__journal_entry_obj)) {
|
||||
console.log(`TEST: Journal Entry updated and changed`, $lq__journal_entry_obj);
|
||||
if (log_lvl) console.log(`Journal Entry forced update:`, $lq__journal_entry_obj);
|
||||
updated_obj = false;
|
||||
orig_entry_obj = { ...$lq__journal_entry_obj };
|
||||
tmp_entry_obj = $lq__journal_entry_obj ? { ...$lq__journal_entry_obj } : {};
|
||||
|
||||
if ($journals_loc?.entry?.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id]) {
|
||||
let decrypt_key = $lq__journal_obj.combined_passcode;
|
||||
|
||||
if (!tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted) {
|
||||
console.log('TEST: Decrypting the content...');
|
||||
|
||||
tmp_entry_obj.content = await ae_util.decrypt_wrapper(
|
||||
tmp_entry_obj?.content_encrypted,
|
||||
decrypt_key
|
||||
@@ -279,8 +188,6 @@
|
||||
orig_entry_obj.content_md_html = handle_marked(orig_entry_obj?.content);
|
||||
}
|
||||
if (!tmp_entry_obj?.history && tmp_entry_obj?.history_encrypted) {
|
||||
console.log('TEST: Decrypting the history...');
|
||||
|
||||
tmp_entry_obj.history = await ae_util.decrypt_wrapper(
|
||||
tmp_entry_obj?.history_encrypted,
|
||||
decrypt_key
|
||||
@@ -296,15 +203,7 @@
|
||||
}
|
||||
|
||||
tmp_entry_obj_changed = false;
|
||||
// updated_obj = false;
|
||||
updated_idb = false;
|
||||
} else if (
|
||||
!updated_obj &&
|
||||
JSON.stringify(orig_entry_obj) !== JSON.stringify($lq__journal_entry_obj)
|
||||
) {
|
||||
console.log('TEST: IDB has changed and not flagged as updated_obj!!!');
|
||||
updated_idb = true;
|
||||
// orig_entry_obj = { ...$lq__journal_entry_obj };
|
||||
}
|
||||
});
|
||||
|
||||
@@ -560,54 +459,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// // Check if the content contains a set of special "cut" XML tags. Anything inside the tags will be moved (appended) to the history field. Anything outside the tags should stay. The content may need to be merged back together if something was cut out of the middle. If no closing tag is found, then cut everything to the end of the content. Be sure to prefix the new history content with a timestamp header in Markdown.
|
||||
// // Example: Hello <cut>Old</cut> World!
|
||||
// // Example header: # Cut on 2024-11-06T12:34:56Z
|
||||
// if (tmp_entry_obj?.content) {
|
||||
// const cutTag = '<cut>';
|
||||
// const cutEndTag = '</cut>';
|
||||
// const cutIndex = tmp_entry_obj.content.indexOf(cutTag);
|
||||
// const cutEndIndex = tmp_entry_obj.content.indexOf(cutEndTag);
|
||||
|
||||
// if (cutIndex !== -1) {
|
||||
// let current_timestamp = new Date().toISOString();
|
||||
// if (cutEndIndex !== -1) {
|
||||
// // Cut everything between the cut tags
|
||||
// const cutContent = tmp_entry_obj.content.substring(cutIndex + cutTag.length, cutEndIndex);
|
||||
// data_kv.history = data_kv.history + '\n\n' + `# Cut on ${current_timestamp}\n` + cutContent;
|
||||
// data_kv.content = tmp_entry_obj.content.replace(cutTag + cutContent + cutEndTag, '');
|
||||
// } else {
|
||||
// // Cut everything after the cut tag
|
||||
// const cutContent = tmp_entry_obj.content.substring(cutIndex + cutTag.length);
|
||||
// data_kv.history = data_kv.history + '\n\n' + `# Cut on ${current_timestamp}\n` + cutContent;
|
||||
// data_kv.content = tmp_entry_obj.content.substring(0, cutIndex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // We also need to support a Markdown variant of the cut tag: ~~cut cut~~.
|
||||
// // Example: Hello ~~CUT: Old :CUT~~ World!
|
||||
// // Example: Hello ~~:: Old ::~~ World!
|
||||
// if (tmp_entry_obj?.content) {
|
||||
// const cutTag = '~~::';
|
||||
// const cutEndTag = '::~~';
|
||||
// const cutIndex = tmp_entry_obj.content.indexOf(cutTag);
|
||||
// const cutEndIndex = tmp_entry_obj.content.indexOf(cutEndTag);
|
||||
|
||||
// if (cutIndex !== -1) {
|
||||
// let current_timestamp = new Date().toISOString();
|
||||
// if (cutEndIndex !== -1) {
|
||||
// // Cut everything between the cut tags
|
||||
// const cutContent = tmp_entry_obj.content.substring(cutIndex + cutTag.length, cutEndIndex);
|
||||
// data_kv.history = data_kv.history + '\n\n' + `# Cut on ${current_timestamp}\n` + cutContent;
|
||||
// data_kv.content = tmp_entry_obj.content.replace(cutTag + cutContent + cutEndTag, '');
|
||||
// } else {
|
||||
// // Cut everything after the cut tag
|
||||
// const cutContent = tmp_entry_obj.content.substring(cutIndex + cutTag.length);
|
||||
// data_kv.history = data_kv.history + '\n\n' + `# Cut on ${current_timestamp}\n` + cutContent;
|
||||
// data_kv.content = tmp_entry_obj.content.substring(0, cutIndex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Call API to save the content
|
||||
try {
|
||||
@@ -777,47 +630,15 @@
|
||||
// }
|
||||
|
||||
async function handle_decrypt_string(encrypted_string: string, passcode: string) {
|
||||
// log_lvl = 1;
|
||||
if (log_lvl) console.log(`TEST: handle_decrypt_string: ${passcode}`, encrypted_string);
|
||||
|
||||
if (!encrypted_string) return '';
|
||||
if (!passcode) return false;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`TEST: handle_decrypt_string: ${passcode}`, encrypted_string);
|
||||
}
|
||||
if (!encrypted_string) {
|
||||
console.log('TEST: No encrypted string provided');
|
||||
return '';
|
||||
}
|
||||
if (!passcode) {
|
||||
console.log('TEST: No journal key provided');
|
||||
return false;
|
||||
}
|
||||
let decrypted_string = await ae_util.decrypt_wrapper(encrypted_string, passcode);
|
||||
if (log_lvl) console.log('TEST: Decrypted string:', decrypted_string);
|
||||
|
||||
let decrypted_string_2 = await ae_util.decrypt_wrapper(encrypted_string, passcode);
|
||||
if (log_lvl) {
|
||||
console.log('TEST: Decrypted string:', decrypted_string_2);
|
||||
}
|
||||
|
||||
return decrypted_string_2;
|
||||
|
||||
// let combined_data = encrypted_string;
|
||||
// let [encryption_iv_hex, encrypted_base64_string] = combined_data.split(':');
|
||||
// encryption_iv = new Uint8Array(encryption_iv_hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
// if (log_lvl) {
|
||||
// console.log(`IV: ${encryption_iv}; Encrypted: ${encrypted_base64_string}`);
|
||||
// }
|
||||
|
||||
// // Decrypt the string using the journal key
|
||||
// let decrypted_string = '';
|
||||
// try {
|
||||
// decrypted_string = await ae_util.decrypt_content(encrypted_base64_string, encryption_iv, passcode);
|
||||
// } catch (error) {
|
||||
// console.error('Error decrypting string:', error);
|
||||
// alert('Failed to decrypt string. Please check the passcode.');
|
||||
// return;
|
||||
// }
|
||||
// if (log_lvl) {
|
||||
// console.log('Decrypted string:', decrypted_string);
|
||||
// }
|
||||
// return decrypted_string;
|
||||
return decrypted_string;
|
||||
}
|
||||
|
||||
// return new_string and cut_string
|
||||
@@ -826,22 +647,12 @@
|
||||
start_tag: string = '<cut>',
|
||||
end_tag: string = '</cut>'
|
||||
) {
|
||||
// Check if the string contains a set of special "cut" XML tags or Markdown. Anything inside the tags or Markdown will be moved (appended) to the history field. Anything outside the tags should stay. The string may need to be merged back together if something was cut out of the middle. If no closing tag is found, then cut everything to the end of the string. Be sure to prefix the new history sting with a timestamp header in Markdown.
|
||||
// Example: Hello <cut>Old</cut> World!
|
||||
// Example header: # Cut on 2024-11-06T12:34:56Z
|
||||
// We also need to support a Markdown variant of the cut tag: ~~cut cut~~.
|
||||
// Example: Hello ~~CUT: Old :CUT~~ World!
|
||||
// Example: Hello ~~:: Old ::~~ World!
|
||||
|
||||
let left_over_string = old_string; // Will be for the updated content field
|
||||
let cut_out_string = ''; // Will be for the history field
|
||||
|
||||
if (old_string) {
|
||||
let start_tag = '<cut>';
|
||||
let end_tag = '</cut>';
|
||||
let cut_index = old_string.indexOf(start_tag);
|
||||
let cut_end_index = old_string.indexOf(end_tag);
|
||||
// let cut_prefix = `# Cut on ${new Date().toISOString()}\n`;
|
||||
|
||||
if (cut_index !== -1) {
|
||||
if (cut_end_index !== -1 && cut_end_index > cut_index) {
|
||||
@@ -860,29 +671,15 @@
|
||||
left_over_string = old_string.substring(0, cut_index).trim();
|
||||
}
|
||||
}
|
||||
// console.log(`Cut out string: "${cut_out_string}"`);
|
||||
}
|
||||
return { left_over_string, cut_out_string };
|
||||
}
|
||||
|
||||
function handle_marked(text_string: string) {
|
||||
if (!text_string) {
|
||||
if (log_lvl) {
|
||||
console.log('No text string provided');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
// let cleaned_string = text_string.replace(/<[^>]*>/g, ''); // Remove HTML tags
|
||||
if (!text_string) return '';
|
||||
|
||||
let cleaned_string = text_string.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '');
|
||||
// let marked_string = marked.parse(text_string);
|
||||
let marked_string = marked.parse(cleaned_string, {
|
||||
// gfm: true,
|
||||
// breaks: true,
|
||||
// headerIds: false,
|
||||
// mangle: false,
|
||||
// xhtml: true,
|
||||
});
|
||||
return marked_string;
|
||||
return marked.parse(cleaned_string);
|
||||
}
|
||||
|
||||
let slct_hosted_file_kv: key_val = $state({});
|
||||
@@ -1729,23 +1526,11 @@
|
||||
] = false;
|
||||
}
|
||||
|
||||
// if ($journals_sess.show__content__journal_entry_history == 'view') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'hide';
|
||||
// } else if ($journals_sess.show__content__journal_entry_history == 'edit') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'hide';
|
||||
// } else if ($journals_sess.show__content__journal_entry_history == 'hide') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'view';
|
||||
// } else if (!$journals_sess.show__content__journal_entry_history) {
|
||||
// $journals_sess.show__content__journal_entry_history = 'view';
|
||||
// }
|
||||
|
||||
// !tmp_entry_obj?.history &&
|
||||
if (tmp_entry_obj?.history_encrypted) {
|
||||
decrypted_history = await ae_util.decrypt_wrapper(
|
||||
tmp_entry_obj?.history_encrypted,
|
||||
journal_key
|
||||
);
|
||||
// decrypted_history = await handle_decrypt_string(tmp_entry_obj.history_encrypted, journal_key);
|
||||
console.log('Decrypted history:', decrypted_history);
|
||||
tmp_entry_obj.history = decrypted_history;
|
||||
}
|
||||
@@ -1764,7 +1549,6 @@
|
||||
{:else if $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history'}
|
||||
<History strokeWidth="2.5" color="red" />
|
||||
{/if}
|
||||
<!-- <History strokeWidth="2.5" color="blue" /> -->
|
||||
<span class="hidden sm:inline text-sm"> Review History</span>
|
||||
</button>
|
||||
|
||||
@@ -1804,7 +1588,6 @@
|
||||
journal_key
|
||||
);
|
||||
|
||||
// decrypted_history = await handle_decrypt_string(tmp_entry_obj.history_encrypted, journal_key);
|
||||
console.log('Decrypted history:', decrypted_history);
|
||||
tmp_entry_obj.history = decrypted_history;
|
||||
|
||||
@@ -1815,7 +1598,6 @@
|
||||
history_md_html =
|
||||
(await marked.parse(history_cleaned ?? '')) ?? null;
|
||||
tmp_entry_obj.history_md_html = history_md_html;
|
||||
// console.log('History cleaned:', history_cleaned);
|
||||
console.log('History md html:', history_md_html);
|
||||
}
|
||||
}}
|
||||
@@ -1846,7 +1628,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Button to call OpenAI API endpoint to summarize the content. -->
|
||||
<!-- AI Summary Logic -->
|
||||
<div
|
||||
class="
|
||||
flex flex-row-reverse flex-wrap gap-1 items-center justify-center
|
||||
@@ -1862,11 +1644,6 @@
|
||||
$journals_loc?.llm__api_dangerous_browser
|
||||
});
|
||||
|
||||
// let resp__models = ai_client.models.list();
|
||||
// console.log('AI API Response (models)', resp__models);
|
||||
|
||||
// let msg_role_system_content = $journals_loc?.entry?.llm__system_prompt || 'You are a helpful assistant that helps people find information.';
|
||||
// let msg_role_user_content = 'Why is the sky blue?';
|
||||
let msg_role_user_content = tmp_entry_obj?.content;
|
||||
|
||||
try {
|
||||
@@ -1883,18 +1660,9 @@
|
||||
},
|
||||
{ role: 'user', content: msg_role_user_content }
|
||||
]
|
||||
// max_tokens: 512,
|
||||
// temperature: 0.7,
|
||||
// stream: true,
|
||||
})
|
||||
.then((resp__chat) => {
|
||||
console.log('AI API Response (chat)', resp__chat);
|
||||
console.log('AI API Response (chat)', resp__chat);
|
||||
|
||||
console.log(
|
||||
'resp msg 0 = ',
|
||||
resp__chat?.choices?.[0]?.message?.content
|
||||
);
|
||||
|
||||
$journals_sess.entry.ai_summary =
|
||||
resp__chat?.choices?.[0]?.message?.content ||
|
||||
@@ -1989,40 +1757,49 @@
|
||||
</button>
|
||||
|
||||
<!-- Set sort order (number) -->
|
||||
<div
|
||||
<span
|
||||
class:hidden={!$ae_loc.edit_mode}
|
||||
class="w-full mb-2 flex flex-row items-center justify-center border border-surface-500/30 rounded-lg p-1 bg-surface-500/5"
|
||||
class="w-full mb-2 flex flex-row flex-wrap items-center justify-center border border-gray-300 rounded-lg"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
if (log_lvl) console.log('Incrementing sort order');
|
||||
tmp_entry_obj.sort = ($lq__journal_entry_obj?.sort ?? 0) + 1;
|
||||
console.log('Incrementing sort order');
|
||||
tmp_entry_obj.sort = $lq__journal_entry_obj?.sort
|
||||
? $lq__journal_entry_obj?.sort + 1
|
||||
: 1;
|
||||
console.log('Incremented sort order:', tmp_entry_obj.sort);
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm preset-tonal-surface hover:preset-filled-secondary-500"
|
||||
class="btn-icon-sm preset-tonal-tertiary transition hover:preset-filled-tertiary-500"
|
||||
title="Increment sort order of this journal entry"
|
||||
>
|
||||
<Plus size="1em" />
|
||||
<Plus strokeWidth="2.5" color="blue" />
|
||||
</button>
|
||||
|
||||
<span class="mx-4 font-bold text-base min-w-[1.5em] text-center">
|
||||
{tmp_entry_obj.sort ?? $lq__journal_entry_obj?.sort ?? 0}
|
||||
<span class="mx-1">
|
||||
{#if $lq__journal_entry_obj?.sort}
|
||||
{$lq__journal_entry_obj.sort}
|
||||
{:else}
|
||||
<!-- <ArrowDown01 /> -->
|
||||
<ArrowDown10 />
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
if (log_lvl) console.log('Decrementing sort order');
|
||||
tmp_entry_obj.sort = Math.max(0, ($lq__journal_entry_obj?.sort ?? 0) - 1);
|
||||
console.log('Decrementing sort order');
|
||||
tmp_entry_obj.sort = $lq__journal_entry_obj?.sort
|
||||
? $lq__journal_entry_obj?.sort - 1
|
||||
: 0;
|
||||
console.log('Decremented sort order:', tmp_entry_obj.sort);
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm preset-tonal-surface hover:preset-filled-secondary-500"
|
||||
class="btn-icon-sm preset-tonal-tertiary transition hover:preset-filled-tertiary-500"
|
||||
title="Decrement sort order of this journal entry"
|
||||
>
|
||||
<Minus size="1em" />
|
||||
<Minus strokeWidth="2.5" color="blue" />
|
||||
</button>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
<!-- Set group (string) -->
|
||||
<input
|
||||
@@ -2734,7 +2511,7 @@ tabindex={$ae_loc.edit_mode ? 0 : -1} -->
|
||||
{/if}
|
||||
|
||||
{#if $lq__journal_entry_obj?.journal_entry_id}
|
||||
<Journal_entry_obj_file_li
|
||||
<Comp_journal_entry_file_li
|
||||
{log_lvl}
|
||||
link_to_type="journal_entry"
|
||||
link_to_id={$lq__journal_entry_obj?.journal_entry_id}
|
||||
@@ -2898,7 +2675,29 @@ zzzz
|
||||
{/if} -->
|
||||
|
||||
<section class="ae_meta flex flex-row flex-wrap gap-1 items-center justify-between w-full">
|
||||
<JournalEntry_Metadata entry={tmp_entry_obj} />
|
||||
<span class="flex flex-row items-center justify-center text-sm text-gray-500">
|
||||
{#if !$ae_loc.edit_mode}
|
||||
<span class="">
|
||||
{ae_util.iso_datetime_formatter(
|
||||
$lq__journal_entry_obj?.created_on,
|
||||
'datetime_iso_12_no_seconds'
|
||||
)}
|
||||
{$lq__journal_entry_obj?.updated_on
|
||||
? ` | Last updated: ${ae_util.iso_datetime_formatter($lq__journal_entry_obj?.updated_on, 'datetime_iso_12_no_seconds')}`
|
||||
: ''}
|
||||
</span>
|
||||
{:else}
|
||||
<span class="">
|
||||
{ae_util.iso_datetime_formatter(
|
||||
$lq__journal_entry_obj?.created_on,
|
||||
'datetime_iso_tz'
|
||||
)}
|
||||
{$lq__journal_entry_obj?.updated_on
|
||||
? ` | Last updated: ${ae_util.iso_datetime_formatter($lq__journal_entry_obj?.updated_on, 'datetime_iso_tz')}`
|
||||
: ''}
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
</section>
|
||||
|
||||
{#if $journals_sess?.entry?.show__ai_summary && $journals_sess?.entry?.ai_summary}
|
||||
|
||||
Reference in New Issue
Block a user