diff --git a/src/routes/journals/JournalEntry_AITools.svelte b/src/routes/journals/JournalEntry_AITools.svelte index d9ce9451..cc31fc65 100644 --- a/src/routes/journals/JournalEntry_AITools.svelte +++ b/src/routes/journals/JournalEntry_AITools.svelte @@ -1,23 +1,30 @@ -
- {#if !$journals_sess?.entry?.show__ai_summary} - {#if entry.content && entry.content.length > 50} - - {:else if entry.summary} - - {/if} + +{#if !$journals_sess?.entry?.show__ai_summary} + {#if entry.content && entry.content.length > 50} + + {:else if entry.summary} + {/if} -
+{/if} + + +{#if $journals_sess?.entry?.show__ai_summary && $journals_sess?.entry?.ai_summary} + +
+
+ + +
+ + +
+
+{/if} \ No newline at end of file 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 de274fd4..fea2222c 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 @@ -92,7 +92,8 @@ import Comp_hosted_files_download_button from '$lib/ae_core/ae_comp__hosted_files_download_button.svelte'; // *** Configuration - let llm_api_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.4y5AStXZJAVnWRlgG3lVV0-xKIfMzqdNRuInGwT0ThQ'; + 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; @@ -123,7 +124,12 @@ // Idiomatic Svelte 5 change detection let tmp_entry_obj_changed = $derived.by(() => { - if (!tmp_entry_obj || !orig_entry_obj || not_obj(tmp_entry_obj) || not_obj(orig_entry_obj)) { + if ( + !tmp_entry_obj || + !orig_entry_obj || + not_obj(tmp_entry_obj) || + not_obj(orig_entry_obj) + ) { return false; } @@ -366,26 +372,18 @@ let { left_over_string, cut_out_string } = handle_cut_string( tmp_entry_obj?.content ); - // Need to decrypt the current content and current history. Assume the history has not been decrypted yet. let content_enc_combined_data = await ae_util.encrypt_wrapper( left_over_string, decrypt_key ); - if (log_lvl) { - console.log('TEST: Encrypted string:', content_enc_combined_data); - } - // return content_enc_combined_data; + + if (log_lvl) console.log('TEST: Encrypted string:', content_enc_combined_data); - // let content_enc_combined_data = await handle_encrypt_string(left_over_string, decrypt_key) data_kv.content_encrypted = content_enc_combined_data; data_kv.content = null; tmp_entry_obj.content = null; - // decrypted_content = ''; - if (log_lvl) { - console.log('TEST: Decrypting the history before saving it...'); - } if (tmp_entry_obj?.history_encrypted) { decrypted_history = await ae_util.decrypt_wrapper( tmp_entry_obj?.history_encrypted, @@ -397,21 +395,15 @@ if (cut_out_string) { let cut_prefix = `# Cut on ${ae_util.iso_datetime_formatter(new Date().toISOString(), 'datetime_iso_12_no_seconds')}\n`; cut_out_string = cut_prefix + cut_out_string; - console.log(`TEST: Cut out string with prefix: "${cut_out_string}"`); } if (tmp_entry_obj?.history?.length && cut_out_string) { - console.log(`HERE 1`); data_kv.history = tmp_entry_obj?.history + '\n' + cut_out_string + '\n'; } else { - console.log(`HERE 2`); data_kv.history = cut_out_string + '\n'; } - console.log('TEST: data_kv.history:', data_kv.history); - if (log_lvl) { - console.log('TEST: Encrypting the history before saving it...'); - } + if (log_lvl) console.log('TEST: Encrypting history...'); let history_enc_combined_data = await ae_util.encrypt_wrapper( data_kv.history, decrypt_key @@ -419,14 +411,10 @@ data_kv.history_encrypted = history_enc_combined_data; data_kv.history = null; - tmp_entry_obj.history; decrypted_history = ''; } } - - - // Call API to save the content try { const response = await journals_func.update_ae_obj__journal_entry({ @@ -435,7 +423,7 @@ data_kv: data_kv, log_lvl: 1 }); - console.log('Journal entry updated successfully:', response); + if (log_lvl) console.log('Journal entry updated successfully:', response); updated_obj = true; } catch (error) { console.error('Error updating journal entry:', error); @@ -449,11 +437,8 @@ return; } - let data_kv = { - journal_id_random: tmp_entry_obj?.journal_id - }; + let data_kv = { journal_id_random: tmp_entry_obj?.journal_id }; - // Call API to save the content try { await journals_func.update_ae_obj__journal_entry({ api_cfg: $ae_api, @@ -463,10 +448,10 @@ }); updated_obj = true; updated_idb = false; - console.log('Journal entry updated successfully!'); + if (log_lvl) console.log('Journal entry journal_id changed successfully!'); } catch (error) { - console.error('Error updating journal entry:', error); - alert('Failed to update journal entry.'); + console.error('Error changing journal ID:', error); + alert('Failed to change journal ID.'); } $journals_slct.journal_id = tmp_entry_obj?.journal_id; goto(`/journals/${tmp_entry_obj?.journal_id}`); @@ -561,12 +546,17 @@ p-2 md:p-3 rounded-lg shadow-md " > -
+
-

+

{#if $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'} {#if $ae_loc.edit_mode && $lq__journal_obj_li?.length}
- -