File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed
Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1+ import os
12from pathlib import Path
23from typing import Optional
34
1213from theflow .settings import settings
1314from theflow .utils .modules import import_dotted_string
1415
16+ BASE_PATH = os .environ .get ('GRADIO_ROOT_PATH' , '' )
1517
1618class BaseApp :
1719 """The main app of Kotaemon
@@ -54,6 +56,8 @@ def __init__(self):
5456 self ._pdf_view_js = self ._pdf_view_js .replace (
5557 "PDFJS_PREBUILT_DIR" ,
5658 pdf_js_dist_dir ,
59+ ).replace (
60+ "GRADIO_ROOT_PATH" , BASE_PATH
5761 )
5862 with (dir_assets / "js" / "svg-pan-zoom.min.js" ).open () as fi :
5963 self ._svg_js = fi .read ()
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ function onBlockLoad () {
1717 <span class="close" id="modal-expand">⛶</span>
1818 </div>
1919 <div class="modal-body">
20- <pdfjs-viewer-element id="pdf-viewer" viewer-path="/file=PDFJS_PREBUILT_DIR" locale="en" phrase="true">
20+ <pdfjs-viewer-element id="pdf-viewer" viewer-path="GRADIO_ROOT_PATH /file=PDFJS_PREBUILT_DIR" locale="en" phrase="true">
2121 </pdfjs-viewer-element>
2222 </div>
2323 </div>
Original file line number Diff line number Diff line change 1- import os . path
1+ import os
22
33import markdown
44from fast_langdetect import detect
55
66from kotaemon .base import RetrievedDocument
77
8+ BASE_PATH = os .environ .get ('GRADIO_ROOT_PATH' , '' )
89
910def is_close (val1 , val2 , tolerance = 1e-9 ):
1011 return abs (val1 - val2 ) <= tolerance
@@ -98,7 +99,7 @@ def preview(
9899
99100 return f"""
100101 { html_content }
101- <a href="#" class="pdf-link" data-src="/file={ pdf_path } " data-page="{ page_idx } " data-search="{ highlight_text } " data-phrase="{ phrase } ">
102+ <a href="#" class="pdf-link" data-src="{ BASE_PATH } /file={ pdf_path } " data-page="{ page_idx } " data-search="{ highlight_text } " data-phrase="{ phrase } ">
102103 [Preview]
103104 </a>
104105 """ # noqa
You can’t perform that action at this time.
0 commit comments