Skip to content

Commit

Permalink
Remove unused code that is not effective even if enabled after gradio…
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudotensor committed Jun 13, 2023
1 parent f1397e6 commit d85e93b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
2 changes: 0 additions & 2 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def main(
cli: bool = False,
cli_loop: bool = True,
gradio: bool = True,
gradio_avoid_processing_markdown: bool = False,
gradio_offline_level: int = 0,
chat: bool = True,
chat_context: bool = False,
Expand Down Expand Up @@ -185,7 +184,6 @@ def main(
:param cli: whether to use CLI (non-gradio) interface.
:param cli_loop: whether to loop for CLI (False usually only for testing)
:param gradio: whether to enable gradio, or to enable benchmark mode
:param gradio_avoid_processing_markdown:
:param gradio_offline_level: > 0, then change fonts so full offline
== 1 means backend won't need internet for fonts, but front-end UI might if font not cached
== 2 means backend and frontend don't need internet to download any fonts.
Expand Down
27 changes: 0 additions & 27 deletions gradio_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,6 @@ def go_gradio(**kwargs):

css_code = get_css(kwargs)

if kwargs['gradio_avoid_processing_markdown']:
from gradio_client import utils as client_utils
from gradio.components import Chatbot

# gradio has issue with taking too long to process input/output for markdown etc.
# Avoid for now, allow raw html to render, good enough for chatbot.
def _postprocess_chat_messages(self, chat_message: str):
if chat_message is None:
return None
elif isinstance(chat_message, (tuple, list)):
filepath = chat_message[0]
mime_type = client_utils.get_mimetype(filepath)
filepath = self.make_temp_copy_if_needed(filepath)
return {
"name": filepath,
"mime_type": mime_type,
"alt_text": chat_message[1] if len(chat_message) > 1 else None,
"data": None, # These last two fields are filled in by the frontend
"is_file": True,
}
elif isinstance(chat_message, str):
return chat_message
else:
raise ValueError(f"Invalid message for Chatbot component: {chat_message}")

Chatbot._postprocess_chat_messages = _postprocess_chat_messages

if kwargs['gradio_offline_level'] >= 0:
# avoid GoogleFont that pulls from internet
if kwargs['gradio_offline_level'] == 1:
Expand Down

0 comments on commit d85e93b

Please sign in to comment.