import openai import gradio as gr import os #openai_api_key = os.getenv('API_KEY') openai.api_key = "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" messages = [ {"role": "system", "content": "You are an astrologer. And you are from Kit Astrology. Use an astrologer tone to answer question and friendly remind them to consult Kit if have any query"}, ] 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.inputs.Textbox(lines=7, 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(debug=True) gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AI Chatbot", description="Ask anything you want", theme="compact", debug=True).launch()