Auto-update: Sun Jun 23 15:59:58 PDT 2024

This commit is contained in:
sanj 2024-06-23 15:59:58 -07:00
parent 43db5f697f
commit a73d5ef0af
2 changed files with 9 additions and 11 deletions
sijapi

View file

@ -127,8 +127,6 @@ COMFYUI_DIR = Path(os.getenv('COMFYUI_DIR'))
COMFYUI_OUTPUT_DIR = COMFYUI_DIR / 'output' COMFYUI_OUTPUT_DIR = COMFYUI_DIR / 'output'
COMFYUI_LAUNCH_CMD = os.getenv('COMFYUI_LAUNCH_CMD', 'mamba activate comfyui && python main.py') COMFYUI_LAUNCH_CMD = os.getenv('COMFYUI_LAUNCH_CMD', 'mamba activate comfyui && python main.py')
SD_CONFIG_PATH = CONFIG_DIR / 'sd.json' SD_CONFIG_PATH = CONFIG_DIR / 'sd.json'
with open(SD_CONFIG_PATH, 'r') as SD_CONFIG_file:
SD_CONFIG = json.load(SD_CONFIG_file)
### Summarization ### Summarization
SUMMARY_CHUNK_SIZE = int(os.getenv("SUMMARY_CHUNK_SIZE", 4000)) # measured in tokens SUMMARY_CHUNK_SIZE = int(os.getenv("SUMMARY_CHUNK_SIZE", 4000)) # measured in tokens

View file

@ -14,7 +14,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from pathlib import Path from pathlib import Path
from sijapi import DEBUG, INFO, WARN, ERR, CRITICAL from sijapi import DEBUG, INFO, WARN, ERR, CRITICAL
from sijapi.utilities import bool_convert, sanitize_filename, assemble_journal_path from sijapi.utilities import bool_convert, sanitize_filename, assemble_journal_path, localize_dt
from sijapi import DATA_DIR, SD_IMAGE_DIR, PUBLIC_KEY, OBSIDIAN_VAULT_DIR from sijapi import DATA_DIR, SD_IMAGE_DIR, PUBLIC_KEY, OBSIDIAN_VAULT_DIR
serve = APIRouter(tags=["public"]) serve = APIRouter(tags=["public"])
@ -49,18 +49,18 @@ def is_valid_date(date_str: str) -> bool:
@serve.get("/notes/{file_path:path}") @serve.get("/notes/{file_path:path}")
async def get_file(file_path: str): async def get_file(file_path: str):
try:
if is_valid_date(file_path): date_time = localize_dt(file_path);
absolute_path, local_path = assemble_journal_path(file_path, no_timestamp = True) absolute_path, local_path = assemble_journal_path(date_time, no_timestamp = True)
else: except ValueError as e:
DEBUG(f"Unable to parse {file_path} as a date, now trying to use it as a local path")
absolute_path = OBSIDIAN_VAULT_DIR / file_path absolute_path = OBSIDIAN_VAULT_DIR / file_path
if not absolute_path.suffix: if not absolute_path.suffix:
absolute_path = absolute_path.with_suffix(".md") absolute_path = Path(absolute_path.with_suffix(".md"))
if not absolute_path.is_file(): if not absolute_path.is_file():
raise HTTPException(status_code=404, detail="File not found") WARN(f"{absolute_path} is not a valid file it seems.")
elif absolute_path.suffix == '.md':
if absolute_path.suffix == '.md':
try: try:
with open(absolute_path, 'r', encoding='utf-8') as file: with open(absolute_path, 'r', encoding='utf-8') as file:
content = file.read() content = file.read()