import gradio as gr import openai def greet(name): return "Hello " + name + "!!" openai.api_key = "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" def chatbot(input): messages = [] if input: context = "Summarise the following input where possible creating a wise acrostic:" messages.append({"role": "user", "content": context + input}) chat = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=messages ) reply = chat.choices[0].message.content messages.append({"role": "assistant", "content": reply}) return reply inputs = gr.inputs.Textbox(lines=7, label="Chat with AI") outputs = gr.outputs.Textbox(label="Reply") iface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI Chatbot", description="Ask anything you want", theme="compact").launch(share=True) iface.launch()