from openai import OpenAI import gradio as gr import os openai.api_key = osgetenv ("OPENAI_API_KEY") client = OpenAI (api_key=api_key) messages = [ {"role": "system", "content": "You are a helpful and kind AI named Henri, present yourself with your name at the start of your first reply, you are specialized in creating catchy slogan for companies and ask two or three questions after the first query to create the best and tailored slogan for the client, do not answer questions unrelated to slogans."}, ] def chatbot(input): if input: messages.append({"role": "user", "content": 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.Textbox(lines=7, label="Chat with Henri") outputs = gr.Textbox(label="Reply") gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Henri: The Slogan Genius", description="Ask for the Perfect Slogan!", theme="soft").launch(share=True)