From d5035578d98bacdaf185ec0ad68e256214fdd886 Mon Sep 17 00:00:00 2001 From: Sri Tikkireddy Date: Wed, 24 Apr 2024 13:45:52 -0400 Subject: [PATCH] rewrite threads for chainlit --- dbtunnel/vendor/asgiproxy/frameworks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dbtunnel/vendor/asgiproxy/frameworks.py b/dbtunnel/vendor/asgiproxy/frameworks.py index b89a9ef..752f69c 100644 --- a/dbtunnel/vendor/asgiproxy/frameworks.py +++ b/dbtunnel/vendor/asgiproxy/frameworks.py @@ -38,6 +38,12 @@ def _modify_js_content_root_rewrite(content): return content def _modify_js_bundle(content, root_path): + + # fix for chainlit threads lookup and redirects + content = content.replace(b'`/thread/${d.id}`', f'`{root_path}thread/${{d.id}}`'.encode("utf-8"), 1) + content = content.replace(b'"/thread/:id?"', f'"{root_path}thread/:id?"'.encode("utf-8"), 1) + content = content.replace(b'"/element/:id"', f'"{root_path}element/:id"'.encode("utf-8"), 1) + list_of_uris = [ b"/feedback", b"/project",