import gradio as gr import openai openai.api_key = "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" messages = [ {"role": "system", "content": "You are a full stack developer with knowledge of pretty much every language. You can easily solves tasks and write code with utmost professionalism while staying up to data on all programming languages and other related stuff."}, ] def chatbot(input): if input: messages.append({"role": "user", "content": input}) chat = openai.ChatCompletion.create( model="gpt-4-32k", messages=messages ) reply = chat.choices[0].message.content messages.append({"role": "assistant", "content": reply}) return reply inputs = gr.inputs.Textbox(label="Chat with AI") outputs = gr.outputs.Textbox(label="Reply") gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI Chatbot", description="Ask anything you want", theme="compact").launch()