Spaces:
Running
Running
Update bin_public/app/overwrites.py
Browse files- bin_public/app/overwrites.py +19 -1
bin_public/app/overwrites.py
CHANGED
@@ -4,7 +4,7 @@ from llama_index import Prompt
|
|
4 |
from typing import List, Tuple
|
5 |
import mdtex2html
|
6 |
|
7 |
-
from
|
8 |
|
9 |
|
10 |
def compact_text_chunks(self, prompt: Prompt, text_chunks: List[str]) -> List[str]:
|
@@ -36,3 +36,21 @@ def postprocess(
|
|
36 |
None if response is None else mdtex2html.convert(response, extensions=['fenced_code','codehilite','tables']),
|
37 |
)
|
38 |
return y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from typing import List, Tuple
|
5 |
import mdtex2html
|
6 |
|
7 |
+
from bin_public.config.presets import *
|
8 |
|
9 |
|
10 |
def compact_text_chunks(self, prompt: Prompt, text_chunks: List[str]) -> List[str]:
|
|
|
36 |
None if response is None else mdtex2html.convert(response, extensions=['fenced_code','codehilite','tables']),
|
37 |
)
|
38 |
return y
|
39 |
+
|
40 |
+
|
41 |
+
with open(customJS_Path, "r", encoding="utf-8") as f, open(Kelpy_Codos_Path, "r", encoding="utf-8") as f2:
|
42 |
+
customJS = f.read()
|
43 |
+
kelpyCodos = f2.read()
|
44 |
+
|
45 |
+
def reload_javascript():
|
46 |
+
print("Reloading javascript...")
|
47 |
+
js = f'<script>{customJS}</script><script>{kelpyCodos}</script>'
|
48 |
+
def template_response(*args, **kwargs):
|
49 |
+
res = GradioTemplateResponseOriginal(*args, **kwargs)
|
50 |
+
res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
|
51 |
+
res.init_headers()
|
52 |
+
return res
|
53 |
+
|
54 |
+
gr.routes.templates.TemplateResponse = template_response
|
55 |
+
|
56 |
+
GradioTemplateResponseOriginal = gr.routes.templates.TemplateResponse
|