File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
Expand file tree Collapse file tree 3 files changed +9
-4
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" , "" )
17+
1518
1619class BaseApp :
1720 """The main app of Kotaemon
@@ -54,7 +57,7 @@ def __init__(self):
5457 self ._pdf_view_js = self ._pdf_view_js .replace (
5558 "PDFJS_PREBUILT_DIR" ,
5659 pdf_js_dist_dir ,
57- )
60+ ). replace ( "GRADIO_ROOT_PATH" , BASE_PATH )
5861 with (dir_assets / "js" / "svg-pan-zoom.min.js" ).open () as fi :
5962 self ._svg_js = fi .read ()
6063
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" , "" )
9+
810
911def is_close (val1 , val2 , tolerance = 1e-9 ):
1012 return abs (val1 - val2 ) <= tolerance
@@ -104,7 +106,7 @@ def preview(
104106
105107 return f"""
106108 { html_content }
107- <a href="#" class="pdf-link" data-src="/file={ pdf_path } " data-page="{ page_idx } " data-search="{ highlight_text } " data-phrase="{ phrase } ">
109+ <a href="#" class="pdf-link" data-src="{ BASE_PATH } /file={ pdf_path } " data-page="{ page_idx } " data-search="{ highlight_text } " data-phrase="{ phrase } ">
108110 [Preview]
109111 </a>
110112 """ # noqa
You can’t perform that action at this time.
0 commit comments