Skip to content

Commit

Permalink
copy button optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovico Mori committed Oct 31, 2023
1 parent a078cb3 commit 160e427
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion A2rchi/interfaces/chat_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class AnswerRenderer(mt.HTMLRenderer):
}

def __init__(self):
self.config = Config_Loader().config
super().__init__()

def block_text(self,text):
Expand All @@ -353,9 +354,14 @@ def block_code(self, code, info=None):
# Handle code blocks (triple backticks)
if info not in self.RENDERING_LEXER_MAPPING.keys(): info = 'bash' #defaults in bash
code_block_highlighted = highlight(code.strip(), self.RENDERING_LEXER_MAPPING[info](stripall=True), HtmlFormatter())

if self.config["interfaces"]["chat_app"]["include_copy_button"]:
button = """<button class="copy-code-btn" onclick="copyCode(this)"> Copy Code </button>"""
else: button = ""

return f"""<div class="code-box">
<div class="code-box-header">
<span>{info}</span> <button class="copy-code-btn" onclick="copyCode(this)"> Copy Code </button>
<span>{info}</span>{button}
</div>
<div class="code-box-body">{code_block_highlighted}
</div>
Expand Down
1 change: 1 addition & 0 deletions config/dev-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interfaces:
template_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/templates"
static_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/static"
num_responses_until_feedback: 3 #the number of responses given by A2rchi until she asks for feedback.
include_copy_button: False
uploader_app:
PORT: 5001
HOST: "0.0.0.0" # either "0.0.0.0" (for public) or "127.0.0.1" (for internal)
Expand Down
1 change: 1 addition & 0 deletions config/prod-801-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interfaces:
template_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/templates"
static_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/static"
num_responses_until_feedback: 3 #the number of responses given by A2rchi until she asks for feedback.
include_copy_button: False
uploader_app:
PORT: 5001
HOST: "0.0.0.0" # either "0.0.0.0" (for public) or "127.0.0.1" (for internal)
Expand Down
1 change: 1 addition & 0 deletions config/prod-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interfaces:
template_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/templates"
static_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/static"
num_responses_until_feedback: 3 #the number of responses given by A2rchi until she asks for feedback.
include_copy_button: False
uploader_app:
PORT: 5001
HOST: "0.0.0.0" # either "0.0.0.0" (for public) or "127.0.0.1" (for internal)
Expand Down
1 change: 1 addition & 0 deletions config/prod-meta-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interfaces:
template_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/templates"
static_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/static"
num_responses_until_feedback: 3 #the number of responses given by A2rchi until she asks for feedback.
include_copy_button: False
uploader_app:
PORT: 5001
HOST: "0.0.0.0" # either "0.0.0.0" (for public) or "127.0.0.1" (for internal)
Expand Down
1 change: 1 addition & 0 deletions config/prod-root-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interfaces:
template_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/templates"
static_folder: "/root/A2rchi/A2rchi/interfaces/chat_app/static"
num_responses_until_feedback: 3 #the number of responses given by A2rchi until she asks for feedback.
include_copy_button: False
uploader_app:
PORT: 5001
HOST: "0.0.0.0" # either "0.0.0.0" (for public) or "127.0.0.1" (for internal)
Expand Down

0 comments on commit 160e427

Please sign in to comment.