Add app title, favicon. More natural chat
This commit is contained in:
parent
513e86f490
commit
757aabca4d
|
@ -41,6 +41,7 @@ class BaseApp:
|
||||||
self._css = fi.read()
|
self._css = fi.read()
|
||||||
with (dir_assets / "js" / "main.js").open() as fi:
|
with (dir_assets / "js" / "main.js").open() as fi:
|
||||||
self._js = fi.read()
|
self._js = fi.read()
|
||||||
|
self._favicon = str(dir_assets / "img" / "favicon.svg")
|
||||||
|
|
||||||
self.default_settings = SettingGroup(
|
self.default_settings = SettingGroup(
|
||||||
application=BaseSettingGroup(settings=settings.SETTINGS_APP),
|
application=BaseSettingGroup(settings=settings.SETTINGS_APP),
|
||||||
|
@ -138,7 +139,7 @@ class BaseApp:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def make(self):
|
def make(self):
|
||||||
with gr.Blocks(css=self._css) as demo:
|
with gr.Blocks(css=self._css, title="Kotaemon") as demo:
|
||||||
self.app = demo
|
self.app = demo
|
||||||
self.settings_state.render()
|
self.settings_state.render()
|
||||||
self.user_id.render()
|
self.user_id.render()
|
||||||
|
|
1
libs/ktem/ktem/assets/img/favicon.svg
Normal file
1
libs/ktem/ktem/assets/img/favicon.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 95.481 95.481" height="95.481" width="95.481" data-background-color="#ffffff" preserveAspectRatio="xMidYMid meet" id="tight-bounds"><g><svg viewBox="0 0 95.481 95.481" height="95.481" width="95.481"><g><svg viewBox="0 0 95.481 95.481" height="95.481" width="95.481"><g id="textblocktransform"><svg viewBox="0 0 95.481 95.481" height="95.481" width="95.481" id="textblock"><g><svg viewBox="0 0 95.481 95.481" height="95.481" width="95.481"><g><svg viewBox="0 0 95.481 95.481" height="95.481" width="95.481"><g><svg/></g><g id="icon-0"><svg viewBox="0 0 95.481 95.481" height="95.481" width="95.481"><g><path xmlns="http://www.w3.org/2000/svg" d="M28.644 95.481c-15.82 0-28.644-12.824-28.644-28.644v-38.193c0-15.82 12.824-28.644 28.644-28.644h38.193c15.82 0 28.644 12.824 28.644 28.644v38.193c0 15.82-12.824 28.644-28.644 28.644z" fill="#000000" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal" data-fill-palette-color="accent"/></g><g transform="matrix(1,0,0,1,19.096200000000003,19.096200000000003)"><svg viewBox="0 0 57.28859999999999 57.28859999999999" height="57.28859999999999" width="57.28859999999999"><g><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0" y="0" viewBox="3.5 3.5 93 93" enable-background="new 0 0 100 100" xml:space="preserve" height="57.28859999999999" width="57.28859999999999" class="icon-y-0" data-fill-palette-color="quaternary" id="y-0" fill="#ffffff"><path d="M83.75 71c-2.976 0-5.71 1.032-7.882 2.747L66.5 64.379V35.621l9.368-9.369C78.04 27.967 80.774 29 83.75 29c7.03 0 12.75-5.72 12.75-12.75S90.78 3.5 83.75 3.5 71 9.22 71 16.25c0 2.976 1.032 5.71 2.747 7.881L64.379 33.5H51.5v-9.75c0-0.829-0.671-1.5-1.5-1.5s-1.5 0.671-1.5 1.5v9.75H35.621l-9.369-9.369C27.967 21.96 29 19.226 29 16.25 29 9.22 23.28 3.5 16.25 3.5S3.5 9.22 3.5 16.25 9.22 29 16.25 29c2.976 0 5.71-1.033 7.881-2.748l9.369 9.369v28.758l-9.369 9.368C21.96 72.032 19.226 71 16.25 71 9.22 71 3.5 76.72 3.5 83.75S9.22 96.5 16.25 96.5 29 90.78 29 83.75c0-2.976-1.033-5.71-2.748-7.882l9.369-9.368h28.758l9.368 9.368C72.032 78.04 71 80.774 71 83.75c0 7.03 5.72 12.75 12.75 12.75S96.5 90.78 96.5 83.75 90.78 71 83.75 71zM83.75 6.5c5.376 0 9.75 4.374 9.75 9.75S89.126 26 83.75 26 74 21.626 74 16.25 78.374 6.5 83.75 6.5zM16.25 26c-5.376 0-9.75-4.374-9.75-9.75s4.374-9.75 9.75-9.75S26 10.874 26 16.25 21.626 26 16.25 26zM16.25 93.5c-5.376 0-9.75-4.374-9.75-9.75S10.874 74 16.25 74 26 78.374 26 83.75 21.626 93.5 16.25 93.5zM63.5 63.5h-27v-27h27V63.5zM83.75 93.5c-5.376 0-9.75-4.374-9.75-9.75S78.374 74 83.75 74s9.75 4.374 9.75 9.75S89.126 93.5 83.75 93.5zM50 56.5c3.584 0 6.5-2.916 6.5-6.5s-2.916-6.5-6.5-6.5-6.5 2.916-6.5 6.5S46.416 56.5 50 56.5zM50 46.5c1.93 0 3.5 1.57 3.5 3.5s-1.57 3.5-3.5 3.5-3.5-1.57-3.5-3.5S48.07 46.5 50 46.5z" fill="#ffffff" data-fill-palette-color="quaternary"/></svg></g></svg></g></svg></g></svg></g></svg></g></svg></g></svg></g><g/></svg></g><defs/></svg>
|
After Width: | Height: | Size: 3.2 KiB |
|
@ -29,9 +29,13 @@ class ChatPage(BasePage):
|
||||||
|
|
||||||
def on_register_events(self):
|
def on_register_events(self):
|
||||||
self.chat_panel.submit_btn.click(
|
self.chat_panel.submit_btn.click(
|
||||||
|
self.chat_panel.submit_msg,
|
||||||
|
inputs=[self.chat_panel.text_input, self.chat_panel.chatbot],
|
||||||
|
outputs=[self.chat_panel.text_input, self.chat_panel.chatbot],
|
||||||
|
show_progress="hidden",
|
||||||
|
).then(
|
||||||
fn=chat_fn,
|
fn=chat_fn,
|
||||||
inputs=[
|
inputs=[
|
||||||
self.chat_panel.text_input,
|
|
||||||
self.chat_panel.chatbot,
|
self.chat_panel.chatbot,
|
||||||
self.data_source.files,
|
self.data_source.files,
|
||||||
self._app.settings_state,
|
self._app.settings_state,
|
||||||
|
@ -41,6 +45,7 @@ class ChatPage(BasePage):
|
||||||
self.chat_panel.chatbot,
|
self.chat_panel.chatbot,
|
||||||
self.info_panel,
|
self.info_panel,
|
||||||
],
|
],
|
||||||
|
show_progress="minimal",
|
||||||
).then(
|
).then(
|
||||||
fn=update_data_source,
|
fn=update_data_source,
|
||||||
inputs=[
|
inputs=[
|
||||||
|
@ -52,9 +57,13 @@ class ChatPage(BasePage):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.chat_panel.text_input.submit(
|
self.chat_panel.text_input.submit(
|
||||||
|
self.chat_panel.submit_msg,
|
||||||
|
inputs=[self.chat_panel.text_input, self.chat_panel.chatbot],
|
||||||
|
outputs=[self.chat_panel.text_input, self.chat_panel.chatbot],
|
||||||
|
show_progress="hidden",
|
||||||
|
).then(
|
||||||
fn=chat_fn,
|
fn=chat_fn,
|
||||||
inputs=[
|
inputs=[
|
||||||
self.chat_panel.text_input,
|
|
||||||
self.chat_panel.chatbot,
|
self.chat_panel.chatbot,
|
||||||
self.data_source.files,
|
self.data_source.files,
|
||||||
self._app.settings_state,
|
self._app.settings_state,
|
||||||
|
@ -64,6 +73,7 @@ class ChatPage(BasePage):
|
||||||
self.chat_panel.chatbot,
|
self.chat_panel.chatbot,
|
||||||
self.info_panel,
|
self.info_panel,
|
||||||
],
|
],
|
||||||
|
show_progress="minimal",
|
||||||
).then(
|
).then(
|
||||||
fn=update_data_source,
|
fn=update_data_source,
|
||||||
inputs=[
|
inputs=[
|
||||||
|
|
|
@ -19,3 +19,7 @@ class ChatPanel(BasePage):
|
||||||
placeholder="Chat input", scale=15, container=False
|
placeholder="Chat input", scale=15, container=False
|
||||||
)
|
)
|
||||||
self.submit_btn = gr.Button(value="Send", scale=1, min_width=10)
|
self.submit_btn = gr.Button(value="Send", scale=1, min_width=10)
|
||||||
|
|
||||||
|
def submit_msg(self, chat_input, chat_history):
|
||||||
|
"""Submit a message to the chatbot"""
|
||||||
|
return "", chat_history + [(chat_input, None)]
|
||||||
|
|
|
@ -114,7 +114,6 @@ class ConversationControl(BasePage):
|
||||||
for result in results:
|
for result in results:
|
||||||
options.append((result.name, result.id))
|
options.append((result.name, result.id))
|
||||||
|
|
||||||
# return gr.update(choices=options)
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
def reload_conv(self, user_id):
|
def reload_conv(self, user_id):
|
||||||
|
|
|
@ -117,8 +117,11 @@ def create_pipeline(settings: dict, files: Optional[list] = None):
|
||||||
return pipeline
|
return pipeline
|
||||||
|
|
||||||
|
|
||||||
async def chat_fn(chat_input, chat_history, files, settings):
|
async def chat_fn(chat_history, files, settings):
|
||||||
"""Chat function"""
|
"""Chat function"""
|
||||||
|
chat_input = chat_history[-1][0]
|
||||||
|
chat_history = chat_history[:-1]
|
||||||
|
|
||||||
queue: asyncio.Queue[Optional[dict]] = asyncio.Queue()
|
queue: asyncio.Queue[Optional[dict]] = asyncio.Queue()
|
||||||
|
|
||||||
# construct the pipeline
|
# construct the pipeline
|
||||||
|
|
|
@ -2,4 +2,4 @@ from ktem.main import App
|
||||||
|
|
||||||
app = App()
|
app = App()
|
||||||
demo = app.make()
|
demo = app.make()
|
||||||
demo.queue().launch()
|
demo.queue().launch(favicon_path=app._favicon)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user