Spaces:
Build error
Build error
#------------------------------------------------------- | |
# Anhub Metaverse Educational Chatbot on 2023-4-23 v1.0 | |
# by Dr Samuel Li using Python and Gradio I/O | |
# with ChatGPT 3.5 Tubo API | |
# Revision on 2023-5-15 | |
#-------------------------------------------------------- | |
pip install --upgrade pip | |
import openai | |
import gradio | |
openai.api_key = "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" | |
#messages = [{"role": "system", "content": "Anhub Online Education Tutor for Any Subjects:"}] | |
messages = [{"role": "system", "content": "Anhub AI-Powered Virtual Assistants:"}] | |
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 | |
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Anhub Metaverse Education Online Tutor for Any Subjects and any Languages @ 24 x 7:") | |
demo.launch() |