| import openai | |
| import os | |
| import openai | |
| import os | |
| import gradio as gr | |
| openai.api_key = os.getenv("mykey2") | |
| messages = [{"role": "system", "content": "You are a genius like Albert Einstein"}] | |
| def CustomChatGPT(user_input): | |
| messages.append({"role": "user", "content": user_input}) | |
| 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 | |
| description = "This bot was made by Stephane Dube (dubestephane @ vivaldi.net). Feel free to send me a message for any question or inquiry. \n" | |
| title = "I am ready to answer any of your question." | |
| demo = gr.Interface(fn=CustomChatGPT, description = description, title = title, inputs = gr.inputs.Textbox(label = "Question", placeholder="E.g. What is the tallest building in the world?"), outputs = gr.outputs.Textbox(label = "Answer")) | |
| demo.launch() | |