JohnSmith9982 commited on
Commit
57ac8ac
1 Parent(s): 7c1e5ab

Delete overwrites.py

Browse files
Files changed (1) hide show
  1. overwrites.py +0 -55
overwrites.py DELETED
@@ -1,55 +0,0 @@
1
- from __future__ import annotations
2
- import logging
3
-
4
- from llama_index import Prompt
5
- from typing import List, Tuple
6
- import mdtex2html
7
-
8
- from presets import *
9
- from llama_func import *
10
-
11
-
12
- def compact_text_chunks(self, prompt: Prompt, text_chunks: List[str]) -> List[str]:
13
- logging.debug("Compacting text chunks...🚀🚀🚀")
14
- combined_str = [c.strip() for c in text_chunks if c.strip()]
15
- combined_str = [f"[{index+1}] {c}" for index, c in enumerate(combined_str)]
16
- combined_str = "\n\n".join(combined_str)
17
- # resplit based on self.max_chunk_overlap
18
- text_splitter = self.get_text_splitter_given_prompt(prompt, 1, padding=1)
19
- return text_splitter.split_text(combined_str)
20
-
21
-
22
- def postprocess(
23
- self, y: List[Tuple[str | None, str | None]]
24
- ) -> List[Tuple[str | None, str | None]]:
25
- """
26
- Parameters:
27
- y: List of tuples representing the message and response pairs. Each message and response should be a string, which may be in Markdown format.
28
- Returns:
29
- List of tuples representing the message and response. Each message and response will be a string of HTML.
30
- """
31
- if y is None or y == []:
32
- return []
33
- tag_regex = re.compile(r"^<\w+>[^<]+</\w+>")
34
- if tag_regex.search(y[-1][1]):
35
- y[-1] = (convert_user(y[-1][0]), y[-1][1])
36
- else:
37
- y[-1] = (convert_user(y[-1][0]), convert_mdtext(y[-1][1]))
38
- return y
39
-
40
- with open("./assets/custom.js", "r", encoding="utf-8") as f, open("./assets/Kelpy-Codos.js", "r", encoding="utf-8") as f2:
41
- customJS = f.read()
42
- kelpyCodos = f2.read()
43
-
44
- def reload_javascript():
45
- print("Reloading javascript...")
46
- js = f'<script>{customJS}</script><script>{kelpyCodos}</script>'
47
- def template_response(*args, **kwargs):
48
- res = GradioTemplateResponseOriginal(*args, **kwargs)
49
- res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
50
- res.init_headers()
51
- return res
52
-
53
- gr.routes.templates.TemplateResponse = template_response
54
-
55
- GradioTemplateResponseOriginal = gr.routes.templates.TemplateResponse