Add app title, favicon. More natural chat

This commit is contained in:
trducng
2024-01-25 22:40:32 +07:00
parent 513e86f490
commit 757aabca4d
7 changed files with 24 additions and 6 deletions

View File

@@ -29,9 +29,13 @@ class ChatPage(BasePage):
def on_register_events(self):
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,
inputs=[
self.chat_panel.text_input,
self.chat_panel.chatbot,
self.data_source.files,
self._app.settings_state,
@@ -41,6 +45,7 @@ class ChatPage(BasePage):
self.chat_panel.chatbot,
self.info_panel,
],
show_progress="minimal",
).then(
fn=update_data_source,
inputs=[
@@ -52,9 +57,13 @@ class ChatPage(BasePage):
)
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,
inputs=[
self.chat_panel.text_input,
self.chat_panel.chatbot,
self.data_source.files,
self._app.settings_state,
@@ -64,6 +73,7 @@ class ChatPage(BasePage):
self.chat_panel.chatbot,
self.info_panel,
],
show_progress="minimal",
).then(
fn=update_data_source,
inputs=[

View File

@@ -19,3 +19,7 @@ class ChatPanel(BasePage):
placeholder="Chat input", scale=15, container=False
)
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)]

View File

@@ -114,7 +114,6 @@ class ConversationControl(BasePage):
for result in results:
options.append((result.name, result.id))
# return gr.update(choices=options)
return options
def reload_conv(self, user_id):

View File

@@ -117,8 +117,11 @@ def create_pipeline(settings: dict, files: Optional[list] = None):
return pipeline
async def chat_fn(chat_input, chat_history, files, settings):
async def chat_fn(chat_history, files, settings):
"""Chat function"""
chat_input = chat_history[-1][0]
chat_history = chat_history[:-1]
queue: asyncio.Queue[Optional[dict]] = asyncio.Queue()
# construct the pipeline