# Imports import gradio as gr from helper_functions import * with gr.Blocks() as app: gr.Markdown('# FundedNext Customer Service Chatbot') # Message Archived, Message Current, User Message, Bot Message session_data = gr.State([ [{"role": "system", "content": pre_text}],[],[],[] ]) with gr.Tab("Chat"): with gr.Row(): with gr.Column(): msg = gr.Textbox() with gr.Row(): submit = gr.Button("Submit") clear = gr.Button("Clear") with gr.Column(): chatbot = gr.Chatbot() with gr.Tab("Prompt"): context = gr.Textbox() submit_p = gr.Button("Check Prompt") with gr.Tab("Download"): file = gr.File(interactive = False) file_download_btn = gr.Button("Downlaod Chat History") # Tab Chat msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then( bot, [chatbot, session_data], [chatbot, session_data] ).then( fn = reset_memory, inputs = session_data, outputs = session_data ) submit.click(user, [msg, chatbot], [msg, chatbot], queue=False).then( bot, [chatbot, session_data], [chatbot, session_data] ).then( fn = reset_memory, inputs = session_data, outputs = session_data ) clear.click( fn = clear_data, inputs = session_data, outputs = [chatbot, session_data], queue = False ) # Tab Prompt submit_p.click(get_context_gr, session_data, context, queue=False) # Tab Download file_download_btn.click(fn = download_file, inputs = session_data, outputs = file, queue = False) # app.launch(debug=True) app.launch(auth=(os.getenv("id"), os.getenv("password")), show_api=False)