CoolFace
Apppublic

tsailada/Emily

sourceHugging Faceotherupdated 3y agoView on Hugging Face
1likes
app.py21 linesDownload Raw Back to root
1import openai2import gradio as gr3 4openai.api_key = "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"5 6messages = [{"role": "system", "content": "You are a post operative nurse"}]7 8def CustomChatGPT(user_input):9    messages.append({"role": "user", "content": user_input})10    response = openai.ChatCompletion.create(11        model="gpt-3.5-turbo",12        messages=messages13    )14    ChatGPT_reply = response["choices"][0]["message"]["content"]15    messages.append({"role": "assistant", "content": ChatGPT_reply})16    return ChatGPT_reply17 18with gr.Blocks(theme=gr.themes.Soft()) as demo:19    demo = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="Emily.AI")20    demo.launch(share=False)21