diff --git a/reasonify-headless/load.py b/reasonify-headless/load.py index e834493..f2f71f9 100644 --- a/reasonify-headless/load.py +++ b/reasonify-headless/load.py @@ -1,3 +1,4 @@ +import sys from functools import cache from os import chdir from pathlib import Path @@ -15,12 +16,17 @@ def with_toast[**Params, Return](message: str) -> Callable[[Callable[Params, Ret for path, source in sources.items(): - file = Path(path) + file = Path("/home/pyodide", path) if not file.parent.is_dir(): file.parent.mkdir(parents=True) file.write_text(source, "utf-8") +if __debug__: + for module in tuple(sys.modules): # for HMR + if module.startswith("reasonify"): + sys.modules.pop(module).__dict__.clear() + if TYPE_CHECKING: class NativeFS: diff --git a/src/lib/components/Chat.svelte b/src/lib/components/Chat.svelte index 09d55e2..79f5049 100644 --- a/src/lib/components/Chat.svelte +++ b/src/lib/components/Chat.svelte @@ -2,13 +2,12 @@ import type { Context } from "../types"; import type { PythonError } from "pyodide/ffi"; - import { type Chain, getPy, initChain } from "../py"; + import { type Chain, initChain } from "../py"; import Highlight from "./Highlight.svelte"; import Markdown from "./Markdown.svelte"; import { dev } from "$app/environment"; import { mount } from "$lib/py/fs"; import { pyodideReady, reasonifyReady, startIconAnimation, stopIconAnimation } from "$lib/stores"; - import { globalCache } from "$lib/utils/cache"; import { toast } from "svelte-sonner"; export let chain: Chain; @@ -23,9 +22,6 @@ async function refresh() { refreshing = true; try { - getPy.invalidateCache(); - globalCache.clear(); - $pyodideReady = false; $reasonifyReady = false; chain = await initChain(); } finally {