Spaces:
Runtime error
Runtime error
Commit
·
9aa425b
1
Parent(s):
8cda24e
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,21 +4,24 @@ import sys
|
|
| 4 |
import argparse
|
| 5 |
from utils import *
|
| 6 |
from chat_func import *
|
|
|
|
| 7 |
|
|
|
|
|
|
|
| 8 |
my_api_key = os.environ.get('my_api_key')
|
| 9 |
|
| 10 |
if my_api_key == "empty":
|
| 11 |
print("Please give a api key!")
|
| 12 |
sys.exit(1)
|
| 13 |
-
|
|
|
|
| 14 |
gr.Chatbot.postprocess = postprocess
|
| 15 |
|
| 16 |
|
| 17 |
with open("css_new.css", "r", encoding="utf-8") as f:
|
| 18 |
css = f.read()
|
| 19 |
|
| 20 |
-
with gr.Blocks(css=css,theme='
|
| 21 |
-
# theme=gr.themes.Soft()
|
| 22 |
history = gr.State([])
|
| 23 |
token_count = gr.State([])
|
| 24 |
promptTemplates = gr.State(load_template('myprompts.json', mode=2))
|
|
@@ -29,7 +32,22 @@ with gr.Blocks(css=css,theme='gstaff/xkcd') as demo:
|
|
| 29 |
|
| 30 |
with gr.Accordion("Build by [45度科研人](WeChat Public Accounts)", open=False):
|
| 31 |
gr.Markdown(description)
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
with gr.Row(scale=1).style(equal_height=True):
|
| 34 |
with gr.Column(scale=5):
|
| 35 |
with gr.Column():
|
|
|
|
| 4 |
import argparse
|
| 5 |
from utils import *
|
| 6 |
from chat_func import *
|
| 7 |
+
from theme_dropdown import create_theme_dropdown
|
| 8 |
|
| 9 |
+
|
| 10 |
+
|
| 11 |
my_api_key = os.environ.get('my_api_key')
|
| 12 |
|
| 13 |
if my_api_key == "empty":
|
| 14 |
print("Please give a api key!")
|
| 15 |
sys.exit(1)
|
| 16 |
+
|
| 17 |
+
dropdown, js = create_theme_dropdown()
|
| 18 |
gr.Chatbot.postprocess = postprocess
|
| 19 |
|
| 20 |
|
| 21 |
with open("css_new.css", "r", encoding="utf-8") as f:
|
| 22 |
css = f.read()
|
| 23 |
|
| 24 |
+
with gr.Blocks(css=css,theme='gradio/soft') as demo:
|
|
|
|
| 25 |
history = gr.State([])
|
| 26 |
token_count = gr.State([])
|
| 27 |
promptTemplates = gr.State(load_template('myprompts.json', mode=2))
|
|
|
|
| 32 |
|
| 33 |
with gr.Accordion("Build by [45度科研人](WeChat Public Accounts)", open=False):
|
| 34 |
gr.Markdown(description)
|
| 35 |
+
|
| 36 |
+
with gr.Column(scale=2):
|
| 37 |
+
with gr.Box():
|
| 38 |
+
dropdown.render()
|
| 39 |
+
toggle_dark = gr.Button(value="Toggle Dark").style(full_width=True)
|
| 40 |
+
|
| 41 |
+
dropdown.change(None, dropdown, None, _js=js)
|
| 42 |
+
toggle_dark.click(
|
| 43 |
+
None,
|
| 44 |
+
_js="""
|
| 45 |
+
() => {
|
| 46 |
+
document.body.classList.toggle('dark');
|
| 47 |
+
document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)'
|
| 48 |
+
}
|
| 49 |
+
""",)
|
| 50 |
+
|
| 51 |
with gr.Row(scale=1).style(equal_height=True):
|
| 52 |
with gr.Column(scale=5):
|
| 53 |
with gr.Column():
|