diff --git a/config.py b/config.py index 4f4a98e..0b9daa0 100644 --- a/config.py +++ b/config.py @@ -8,40 +8,28 @@ # - 0.4 to 0.7: Balanced, conversational (Good for general writing) # - 0.8 to 1.0: Highly creative, unpredictable (Good for brainstorming) TEMPERATURES = { - # The global fallback used if a script doesn't have a specific setting. - "default": 0.2, + "default": 0.2, # The global fallback # Specific script overrides. - # Replace 'None' with a float to override the default. - "insights": None, # generate_insights.py - "briefing": None, # morning_briefing.py - "recap": None, # study_recap.py - "txt": None, # txt_to_notes.py + # Replace 'None' with a float (0.0-1.0) to override. + "insights": None, + "briefing": None, + "recap": None, + "txt": None, } -# ------------------------------------------------------------- -# API Configuration -# ------------------------------------------------------------- -OLLAMA_API_URL = "http://localhost:11434/api/generate" # Ollama API endpoint - -TIMEOUT = 1000 # Max seconds to wait for a response per call. - # Increase for slow hardware or large prompts. Default: 1000 - -KEEP_ALIVE = "10m" # How long Ollama keeps the model loaded after last request. - # Format: "5m", "1h", "0" (unload immediately). Default: "10m" - -NUM_CTX = 8192 # Context window size in tokens. - # Higher = more notes fit in prompt but uses more RAM. - # Recommended: 4096 (fast) to 16384 (large vaults). Default: 8192 - # ------------------------------------------------------------- # Vault Configuration # ------------------------------------------------------------- -VAULT_PATH = "~/Obsidian" # Path to your Obsidian vault. Supports ~ for home directory. +VAULT_PATH = "~/Obsidian" # Path to your Obsidian vault. # ------------------------------------------------------------- # Script Behaviour # ------------------------------------------------------------- +DAYS_BACK = 7 +HOURS_BACK = 24 +MAX_NOTE_CHARS = 2000 +MAX_FILE_SIZE = 1_000_000 DAYS_BACK = 7 # generate_insights.py: how many days back to collect notes. # 7 = weekly report, 30 = monthly report. @@ -64,6 +52,7 @@ # "Archive", ] + #-------------------------------------------------------------- # Tagging System (generate_insights.py) #-------------------------------------------------------------- @@ -93,4 +82,13 @@ RECAP_TITLE_FORMAT = "{date} ({time}) Study Recap — {subject}.md" # Placeholders: {title} -TXT_TITLE_FORMAT = "{title}.md" \ No newline at end of file +TXT_TITLE_FORMAT = "{title}.md" + + +# ------------------------------------------------------------- +# API Configuration +# ------------------------------------------------------------- +OLLAMA_API_URL = "http://localhost:11434/api/generate" +TIMEOUT = 1000 +KEEP_ALIVE = "10m" +NUM_CTX = 8192 \ No newline at end of file diff --git a/generate_insights.py b/generate_insights.py index 9fccc6e..d18e116 100644 --- a/generate_insights.py +++ b/generate_insights.py @@ -17,6 +17,7 @@ import sys import json +import re import datetime from pathlib import Path from concurrent.futures import ThreadPoolExecutor, as_completed @@ -36,10 +37,14 @@ with PROMPTS_PATH.open(encoding="utf-8") as f: PROMPTS = json.load(f) +TEMP_INSIGHTS = TEMPERATURES.get("insights") + GROUNDING = PROMPTS["grounding"] LENSES = PROMPTS["insights"]["lenses"] -TEMP_INSIGHTS = TEMPERATURES.get("insights") +def format_obsidian_tag(text: str) -> str: + text = text.lower().replace(" ", "-") + return re.sub(r'[^a-z0-9_-]', '', text) def fill_prompt(template: str, **kwargs) -> str: """ @@ -245,7 +250,13 @@ def extract_tags(lens_results: list[dict], synthesis: str) -> list[str]: if any(kw in text for kw in keywords): base_tags.append(tag) - return base_tags[:6] + final_tags = [] + for tag in base_tags: + cleaned = format_obsidian_tag(tag) + if cleaned: + final_tags.append(cleaned) + + return final_tags[:6] # --- OUTPUT --- @@ -273,7 +284,7 @@ def write_insight_note(lens_results: list[dict], synthesis: str, note_count: int fm_lines = [ "---", - f"creation date: + {date_str}", + f"creation date: {date_str}", "tags:" ] + [f" - {t}" for t in tags] + [ time_property, diff --git a/morning_briefing.py b/morning_briefing.py index 3042605..ca00ef9 100644 --- a/morning_briefing.py +++ b/morning_briefing.py @@ -30,6 +30,8 @@ PROMPTS_PATH = SCRIPT_DIR / "prompts.json" with PROMPTS_PATH.open(encoding="utf-8") as f: PROMPTS = json.load(f) + +TEMP_BRIEFING = TEMPERATURES.get("briefing") GROUNDING = PROMPTS["grounding"] diff --git a/study_recap.py b/study_recap.py index a13b33b..827978a 100644 --- a/study_recap.py +++ b/study_recap.py @@ -28,6 +28,8 @@ with PROMPTS_PATH.open(encoding="utf-8") as f: PROMPTS = json.load(f) +TEMP_RECAP = TEMPERATURES.get("recap") + GROUNDING = PROMPTS["grounding"] TEMP_RECAP = TEMPERATURES.get("recap") diff --git a/txt_to_notes.py b/txt_to_notes.py index 8494b89..a83f3db 100644 --- a/txt_to_notes.py +++ b/txt_to_notes.py @@ -38,6 +38,9 @@ with PROMPTS_PATH.open(encoding="utf-8") as f: PROMPTS = json.load(f) + +TEMP_TXT = TEMPERATURES.get("txt") + GROUNDING = PROMPTS["grounding"] R = "\033[0m" @@ -48,8 +51,6 @@ GREEN = "\033[32m" RED = "\033[31m" -TEMP_TXT = TEMPERATURES.get("txt") - def format_obsidian_tag(text: str) -> str: text = text.lower().replace(" ", "-") return re.sub(r'[^a-z0-9_-]', '', text)