Team Ai
Apppublic

majweldon/ScienceForTheWin

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
app.py31 linesDownload Raw Back to root
1import gradio as gr2import random3import time4import os5 6openai_secret_key = os.environ.get('OPENAI_SECRET_KEY')7with open("Format_Library/Weldon_Handover_Note_Format.txt", "r") as f:8    role = f.read()9role_head = role[0:50]10 11with gr.Blocks() as demo:12    chatbot = gr.Chatbot()13    msg = gr.Textbox()14    clear = gr.Button("Clear")15 16    def user(user_message, history):17        return "", history + [[user_message, None]]18 19    def bot(history):20        bot_message = random.choice(["Yes", role_head])21        history[-1][1] = bot_message22        time.sleep(1)23        return history24 25    msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(26        bot, chatbot, chatbot27    )28    clear.click(lambda: None, None, chatbot, queue=False)29 30demo.launch()31