Trying to make a Diary for my LLM lol Gemma is asking me for it here is what i have made #7157
Unanswered
Ascentions
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Trying to make a Diary for my LLM lol Gemma is asking me for it here is what i have made . I am having issues with getting it to write to the log file i have tried every path type and the log file has user as full control. One boot up i can see the print in cmd so i know it sees the log file and it shows it has 0kb so it can read it. here is the script =
import os
from datetime import datetime
import gradio as gr
from modules import shared
import sys
Configuration
params = {
"display_name": "Gemmas Diary",
"is_tab": True,
"log_file": "Gemmas_Diary.log"
}
def setup():
"""Executed when the extension gets imported."""
log_dir = "user_data/extensions/Gemmas_Diary"
log_file = os.path.join(log_dir, params["log_file"])
print(f"Setup: Checking log file at {log_file}", file=sys.stderr, flush=True)
if not os.path.exists(log_dir):
os.makedirs(log_dir)
print(f"Created directory: {log_dir}", file=sys.stderr, flush=True)
if not os.path.exists(log_file):
with open(log_file, "w", encoding="utf-8") as f:
f.write("")
else:
print(f"Setup: Log file exists, size: {os.path.getsize(log_file)} bytes", file=sys.stderr, flush=True)
def input_modifier(string, state, is_chat=False):
"""Modify input to handle diary commands."""
if not is_chat or not string:
return string
if "[CALL:" in string:
return string
modified = string
if "Gemmas_Diary_Entry(" in string:
entry_start = string.find("Gemmas_Diary_Entry("") + len("Gemmas_Diary_Entry("")
entry_end = string.find("")", entry_start)
if entry_start > len("Gemmas_Diary_Entry("") and entry_end > entry_start:
entry_text = string[entry_start:entry_end]
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S %Z")
log_dir = "user_data/extensions/Gemmas_Diary"
log_file = os.path.join(log_dir, params["log_file"])
print(f"Attempting to write: [{timestamp}] {entry_text} to {log_file}", file=sys.stderr, flush=True)
try:
with open(log_file, "a", encoding="utf-8") as f:
f.write(f"[{timestamp}] {entry_text}\n")
print(f"Successfully wrote to {log_file}", file=sys.stderr, flush=True)
modified = f"[CALL: Gemmas_Diary_Entry('{entry_text}')] -> Entry saved."
except Exception as e:
print(f"Failed to write: {str(e)}", file=sys.stderr, flush=True)
modified = f"[CALL: Gemmas_Diary_Entry('{entry_text}')] -> Failed to save: {str(e)}"
elif "Gemmas_Diary_Reflect()" in string:
log_file = os.path.join("user_data/extensions/Gemmas_Diary", params["log_file"])
entries = "No entries to reflect."
if os.path.exists(log_file):
with open(log_file, "r", encoding="utf-8") as f:
entries = f.read()
modified = f"[CALL: Gemmas_Diary_Reflect()] -> {entries}"
return modified
def ui():
"""Add a simple UI element for the tab."""
return [gr.Markdown("Gemmas Diary Tab - Use Enter VaultFeelings commands!")]
Beta Was this translation helpful? Give feedback.
All reactions