import gradio as gr import openai openai.api_key = "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" messages = [{"role": "system", "content": "You are a Twitter Tweets expert that specializes in creating viral tweets for startup marketing and updates."}] def CustomChatGPT(message): messages.append({"role": "user", "content": message}) response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=messages ) ChatGPT_reply = response["choices"][0]["message"]["content"] messages.append({"role": "assistant", "content": ChatGPT_reply}) return ChatGPT_reply demo = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="Twitter Tweets Pro", inputs_label="Enter a message") demo.launch()