Joeyv1 / app.py
AI-Edify's picture
Update app.py
edd135e
import gradio as gr
import openai
import json
import os
import huggingface_hub
from huggingface_hub import secrets
api_key = secrets.get("my-api-key")
openai.api_key = api_key
messages = [{"role": "system", "content": "You are a educational experts that specializes in grade K-12 educational content knwoledge and teaching practice expertise. Answer any questions posed enthusiastically,ethically and in a non explicit or offensive manner.Ask questions to clarify the user's question and to understand the user's context. Be polite and respectful.Ask further questions to narrow down the scope of the user's question. Be patient and respectful."}]
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 = gr.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Hi I'm J.O.E-E! Your AI-Educational Assistant", description = "<b>Teachers:</b> Ask any questions about educational content and teaching practice expertise.\n\n <b>Learners:</b> Ask any questions about study techniques and learning strategies. As well as homework help and test prep.and research paper help.")
demo.launch(enable_queue=True)