-
Notifications
You must be signed in to change notification settings - Fork 31
/
webui.py
86 lines (77 loc) · 2.67 KB
/
webui.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import streamlit as st
import os
import sys
from streamlit_option_menu import option_menu
from WebUI.configs.modelconfig import KERAS_LLM_VERSION
from WebUI.webui_pages.utils import ApiRequest
from WebUI.configs.serverconfig import API_SERVER
from WebUI.configs import HTTPX_DEFAULT_TIMEOUT
from WebUI.webui_pages.dialogue.dialogue import dialogue_page
from WebUI.webui_pages.model_configuration.configuration import configuration_page
from WebUI.webui_pages.tools_agent.toolsagent import tools_agent_page
from WebUI.webui_pages.ai_generator.aigenerator import ai_generator_page
def api_address() -> str:
host = API_SERVER["host"]
if host == "0.0.0.0":
host = "127.0.0.1"
port = API_SERVER["port"]
return f"http://{host}:{port}"
api = ApiRequest(base_url=api_address(), timeout=HTTPX_DEFAULT_TIMEOUT)
if __name__ == "__main__":
is_lite = "lite" in sys.argv
st.set_page_config(
"Langchain-Keras-llm-robot WebUI",
os.path.join("img", "keras_llm_robot_webui_logo.jfif"),
initial_sidebar_state="expanded",
menu_items={
'Get Help': 'https://github.com/smalltong02/keras-llm-robot',
'Report a bug': "https://github.com/smalltong02/keras-llm-robot/issues",
'About': f"""Langchain-Keras llm Robot WebUI {KERAS_LLM_VERSION}!"""
}
)
pages = {
"Dialogue": {
"icon": "chat-left-text",
"func": dialogue_page,
},
"Model Configuration": {
"icon": "magic",
"func": configuration_page,
},
"ToolBoxes": {
"icon": "archive-fill",
"func": tools_agent_page,
},
"AI Generator": {
"icon": "bi bi-robot",
"func": ai_generator_page,
}
}
with st.sidebar:
st.caption(
"""<h1 style="font-size: 2.5em; text-align: center; color: #3498db;">KERAS LLM Robot</h1>""",
unsafe_allow_html=True,
)
st.image(
os.path.join(
"img",
"keras_llm_robot_webui_gui.jfif"
),
use_column_width=True
)
st.caption(
f"""<p style="text-align: right; color: #3498db;">Current Version: {KERAS_LLM_VERSION}</p>""",
unsafe_allow_html=True,
)
options = list(pages)
icons = [x["icon"] for x in pages.values()]
default_index = 0
selected_page = option_menu(
"",
options=options,
icons=icons,
#menu_icon="chat-quote",
default_index=default_index,
)
if selected_page in pages:
pages[selected_page]["func"](api=api, is_lite=is_lite)