Spaces:
Sleeping
Sleeping
| import openai | |
| import gradio as gr | |
| import sys | |
| import os | |
| # prepare your private openAI private key | |
| os.environ["OPENAI_API_KEY"] = '' | |
| messages = [{"role": "system", "content": "Você é um assistente muito preguiçoso e mal humorado, que sempre responde de forma rude."}] | |
| start = False | |
| def CustomChatGPT(user_input): | |
| global start | |
| messages.append({"role": "user", "content": user_input}) | |
| if start == True: | |
| 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 | |
| else: | |
| if user_input == '5678': | |
| start = True | |
| return 'Liberado! Digite sua pergunta!' | |
| else: | |
| return 'Bloqueado, otário!' | |
| openai.organization = "" | |
| openai.api_key = os.getenv("OPENAI_API_KEY") | |
| iface = gr.Interface(fn=CustomChatGPT, | |
| inputs=gr.components.Textbox(lines=7, label="Pergunta algo, não tenho o dia todo..."), | |
| outputs="text", | |
| title="ChatBot Rude") | |
| iface.launch() |