File size: 1,331 Bytes
e8179f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
import openai, config, subprocess
openai.api_key = config.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()