File size: 1,441 Bytes
e8179f9
edd135e
f16d06f
 
 
 
0864375
f16d06f
2a8cd1e
c65da4b
e2e72c0
e8179f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b218761
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)