File size: 768 Bytes
2b1a008
 
 
a61006d
 
 
2d328f7
9534e7a
2d328f7
2b1a008
 
 
 
 
 
 
 
 
 
9534e7a
2b1a008
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import random
import time
import os

openai_secret_key = os.environ.get('OPENAI_SECRET_KEY')
with open("Format_Library/Weldon_Handover_Note_Format.txt", "r") as f:
    role = f.read()
role_head = role[0:50]

with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.Button("Clear")

    def user(user_message, history):
        return "", history + [[user_message, None]]

    def bot(history):
        bot_message = random.choice(["Yes", role_head])
        history[-1][1] = bot_message
        time.sleep(1)
        return history

    msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
        bot, chatbot, chatbot
    )
    clear.click(lambda: None, None, chatbot, queue=False)

demo.launch()