-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
56 lines (44 loc) · 1.34 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# app.py : Multimodal Chatbot
import gradio as gr
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
import app_tmpl
import app_chat_v3
import app_orchestration
import app_create_v2
TABS = {
'AI Chat': app_chat_v3.get_demo,
'AI Orchestration': app_orchestration.get_demo,
'AI Create': app_create_v2.get_demo,
'Template': app_tmpl.get_demo,
}
css="""#chatbot {
min-height: 600px;
}"""
def get_demo():
with gr.Blocks(css=css) as demo:
for name, get_tab_func in TABS.items():
with gr.Tab(name):
get_tab_func()
return demo
def parse_args():
"""Parse input arguments."""
import argparse
parser = argparse.ArgumentParser(
description='Multimodal Chatbot',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-p', '--port', default=7860, type=int,
help='port number.')
parser.add_argument(
'--debug', action='store_true',
help='debug mode.')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = parse_args()
# WARNING: gobal variables are shared accross users, and should be avoided.
demo = get_demo()
from utils import reload_javascript
reload_javascript()
demo.queue().launch(server_name='0.0.0.0', server_port=args.port)