mena88/AI_stuff
0
1pip install openai2pip install gradio3 4 5import openai6import gradio as gr7 8openai.api_key = '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'9 10messages = [11 {"role": "system", "content": "You are a helpful and kind AI Assistant."},12]13 14def chatbot(input):15 if input:16 messages.append({"role": "user", "content": input})17 chat = openai.ChatCompletion.create(18 model="gpt-3.5-turbo", messages=messages19 )20 reply = chat.choices[0].message.content21 messages.append({"role": "assistant", "content": reply})22 return reply23 24inputs = gr.inputs.Textbox(lines=7, label="Chat with Prevent's AI")25outputs = gr.outputs.Textbox(label="Reply")26 27gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Diabetes AI Chatbot",28 description="Ask anything about diabetes",29 theme="compact").launch(share=True)30 