Improve manuals (#19)

* Rename Admin -> Resources
* Improve ui
* Update docs
This commit is contained in:
ian_Cin
2024-04-10 17:04:04 +07:00
committed by GitHub
parent 7b3307e3c4
commit b507eef541
26 changed files with 202 additions and 175 deletions

View File

@@ -1,3 +1,7 @@
:root {
--main-area-height: calc(100vh - 110px);
}
/* no footer */
footer {
display: none !important;
@@ -14,11 +18,13 @@ footer {
background-clip: content-box;
}
::-webkit-scrollbar-corner {
background: var(--border-color-primary);
background: var(--background-fill-primary);
}
.gradio-container {
max-width: 100% !important;
/* overflow: scroll !important;
height: 100% !important; */
}
/* styling for header bar */
@@ -70,15 +76,25 @@ button.selected {
}
#main-chat-bot {
/* span the chat area to occupy full height minus space for chat input */
height: calc(100vh - 180px) !important;
flex: 1;
}
#chat-area {
height: var(--main-area-height) !important;
}
#chat-info-panel {
max-height: calc(100vh - 180px) !important;
max-height: var(--main-area-height) !important;
overflow-y: scroll !important;
}
#conv-settings-panel {
max-height: var(--main-area-height) !important;
flex-wrap: unset;
overflow-y: scroll !important;
position: sticky;
}
.setting-answer-mode-description {
margin: 5px 5px 2px !important;
}
@@ -124,6 +140,18 @@ button.selected {
}
/* for setting height limit for buttons */
.cap-height {
.cap-button-height {
max-height: 42px;
}
.scrollable {
overflow-y: auto;
}
.fill-main-area-height {
max-height: var(--main-area-height);
}
.unset-overflow {
overflow: unset !important;
}

View File

@@ -101,15 +101,16 @@ class FileIndexPage(BasePage):
with gr.Column(scale=1):
gr.Markdown("## File Upload")
with gr.Column() as self.upload:
msg = self.upload_instruction()
if msg:
gr.Markdown(msg)
self.files = File(
file_types=self._supported_file_types,
file_count="multiple",
container=True,
)
msg = self.upload_instruction()
if msg:
gr.Markdown(msg)
with gr.Accordion("Advanced indexing options", open=True):
with gr.Row():
self.reindex = gr.Checkbox(
@@ -346,7 +347,7 @@ class FileIndexPage(BasePage):
# download the file
text = "\n\n".join([each.text for each in output_nodes])
handler, file_path = tempfile.mkstemp(suffix=".txt")
with open(file_path, "w") as f:
with open(file_path, "w", encoding="utf-8") as f:
f.write(text)
os.close(handler)

View File

@@ -1,8 +1,8 @@
import gradio as gr
from ktem.app import BaseApp
from ktem.pages.admin import AdminPage
from ktem.pages.chat import ChatPage
from ktem.pages.help import HelpPage
from ktem.pages.resources import ResourcesTab
from ktem.pages.settings import SettingsPage
@@ -57,14 +57,16 @@ class App(BaseApp):
elem_id="resources-tab",
id="resources-tab",
visible=not self.f_user_management,
elem_classes=["fill-main-area-height", "scrollable"],
) as self._tabs["resources-tab"]:
self.admin_page = AdminPage(self)
self.resources_page = ResourcesTab(self)
with gr.Tab(
"Settings",
elem_id="settings-tab",
id="settings-tab",
visible=not self.f_user_management,
elem_classes=["fill-main-area-height", "scrollable"],
) as self._tabs["settings-tab"]:
self.settings_page = SettingsPage(self)
@@ -73,6 +75,7 @@ class App(BaseApp):
elem_id="help-tab",
id="help-tab",
visible=not self.f_user_management,
elem_classes=["fill-main-area-height", "scrollable"],
) as self._tabs["help-tab"]:
self.help_page = HelpPage(self)

View File

@@ -27,7 +27,7 @@ class ChatPage(BasePage):
def on_building_ui(self):
with gr.Row():
self.chat_state = gr.State(STATE)
with gr.Column(scale=1):
with gr.Column(scale=1, elem_id="conv-settings-panel"):
self.chat_control = ConversationControl(self._app)
if getattr(flowsettings, "KH_FEATURE_CHAT_SUGGESTION", False):
@@ -60,7 +60,7 @@ class ChatPage(BasePage):
self.report_issue = ReportIssue(self._app)
with gr.Column(scale=6):
with gr.Column(scale=6, elem_id="chat-area"):
self.chat_panel = ChatPanel(self._app)
with gr.Column(scale=3):

View File

@@ -22,19 +22,20 @@ class ChatPanel(BasePage):
placeholder="Chat input",
scale=15,
container=False,
max_lines=10,
)
self.submit_btn = gr.Button(
value="Send",
scale=1,
min_width=10,
variant="primary",
elem_classes=["cap-height"],
elem_classes=["cap-button-height"],
)
self.regen_btn = gr.Button(
value="Regen",
scale=1,
min_width=10,
elem_classes=["cap-height"],
elem_classes=["cap-button-height"],
)
def submit_msg(self, chat_input, chat_history):

View File

@@ -37,6 +37,7 @@ class ConversationControl(BasePage):
container=False,
filterable=False,
interactive=True,
elem_classes=["unset-overflow"],
)
with gr.Row() as self._new_delete:

View File

@@ -28,8 +28,10 @@ class ReportIssue(BasePage):
label="Other issue:",
)
self.more_detail = gr.Textbox(
placeholder="More detail (e.g. how wrong is it, what is the "
"correct answer, etc...)",
placeholder=(
"More detail (e.g. how wrong is it, what is the "
"correct answer, etc...)"
),
container=False,
lines=3,
)

View File

@@ -7,18 +7,15 @@ class HelpPage:
def __init__(self, app):
self._app = app
self.dir_md = Path(__file__).parent.parent / "assets" / "md"
self.doc_dir = Path(__file__).parents[4] / "docs"
with gr.Accordion("User Guide"):
with (self.doc_dir / "usage.md").open(encoding="utf-8") as fi:
gr.Markdown(fi.read())
with gr.Accordion("Changelogs"):
gr.Markdown(self.get_changelogs())
with gr.Accordion("About Kotaemon (temporary)"):
with (self.dir_md / "about_kotaemon.md").open(encoding="utf-8") as fi:
gr.Markdown(fi.read())
with gr.Accordion("About Cinnamon AI (temporary)", open=False):
with (self.dir_md / "about_cinnamon.md").open(encoding="utf-8") as fi:
gr.Markdown(fi.read())
def get_changelogs(self):
with (self.dir_md / "changelogs.md").open(encoding="utf-8") as fi:
return fi.read()

View File

@@ -8,7 +8,7 @@ from sqlmodel import Session, select
from .user import UserManagement
class AdminPage(BasePage):
class ResourcesTab(BasePage):
def __init__(self, app):
self._app = app
self.on_building_ui()
@@ -21,7 +21,7 @@ class AdminPage(BasePage):
with gr.Tab("LLMs") as self.llm_management_tab:
self.llm_management = LLMManagement(self._app)
with gr.Tab("Embeddings") as self.llm_management_tab:
with gr.Tab("Embedding Models") as self.llm_management_tab:
self.emb_management = EmbeddingManagement(self._app)
def on_subscribe_public_events(self):