From 1a4acb924b7e161a3184e000a13642f0d043c30d Mon Sep 17 00:00:00 2001
From: yanqiangmiffy <1185918903@qq.com>
Date: Wed, 19 Apr 2023 01:46:46 +0800
Subject: [PATCH] update@css
---
README.md | 1 +
app_modules/overwrites.py | 57 ++++++
app_modules/presets.py | 82 ++++++++
app_modules/utils.py | 382 ++++++++++++++++++++++++++++++++++++++
assets/Kelpy-Codos.js | 76 ++++++++
assets/custom.css | 190 +++++++++++++++++++
assets/custom.js | 1 +
assets/favicon.ico | Bin 0 -> 15406 bytes
main.py | 13 +-
9 files changed, 797 insertions(+), 5 deletions(-)
create mode 100644 app_modules/overwrites.py
create mode 100644 app_modules/presets.py
create mode 100644 app_modules/utils.py
create mode 100644 assets/Kelpy-Codos.js
create mode 100644 assets/custom.css
create mode 100644 assets/custom.js
create mode 100644 assets/favicon.ico
diff --git a/README.md b/README.md
index f376739..83ce373 100644
--- a/README.md
+++ b/README.md
@@ -47,3 +47,4 @@
- webui参考:https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui
- knowledge问答参考:https://github.com/imClumsyPanda/langchain-ChatGLM
- LLM模型:https://github.com/THUDM/ChatGLM-6B
+- CSS:https://huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT
\ No newline at end of file
diff --git a/app_modules/overwrites.py b/app_modules/overwrites.py
new file mode 100644
index 0000000..4bfa339
--- /dev/null
+++ b/app_modules/overwrites.py
@@ -0,0 +1,57 @@
+from __future__ import annotations
+import logging
+
+from llama_index import Prompt
+from typing import List, Tuple
+import mdtex2html
+
+from app_modules.presets import *
+from app_modules.utils import *
+
+def compact_text_chunks(self, prompt: Prompt, text_chunks: List[str]) -> List[str]:
+ logging.debug("Compacting text chunks...🚀🚀🚀")
+ combined_str = [c.strip() for c in text_chunks if c.strip()]
+ combined_str = [f"[{index+1}] {c}" for index, c in enumerate(combined_str)]
+ combined_str = "\n\n".join(combined_str)
+ # resplit based on self.max_chunk_overlap
+ text_splitter = self.get_text_splitter_given_prompt(prompt, 1, padding=1)
+ return text_splitter.split_text(combined_str)
+
+
+def postprocess(
+ self, y: List[Tuple[str | None, str | None]]
+) -> List[Tuple[str | None, str | None]]:
+ """
+ Parameters:
+ y: List of tuples representing the message and response pairs. Each message and response should be a string, which may be in Markdown format.
+ Returns:
+ List of tuples representing the message and response. Each message and response will be a string of HTML.
+ """
+ if y is None or y == []:
+ return []
+ temp = []
+ for x in y:
+ user, bot = x
+ if not detect_converted_mark(user):
+ user = convert_asis(user)
+ if not detect_converted_mark(bot):
+ bot = convert_mdtext(bot)
+ temp.append((user, bot))
+ return temp
+
+with open("./assets/custom.js", "r", encoding="utf-8") as f, open("./assets/Kelpy-Codos.js", "r", encoding="utf-8") as f2:
+ customJS = f.read()
+ kelpyCodos = f2.read()
+
+def reload_javascript():
+ print("Reloading javascript...")
+ js = f''
+ def template_response(*args, **kwargs):
+ res = GradioTemplateResponseOriginal(*args, **kwargs)
+ res.body = res.body.replace(b'