Spaces:
No application file
No application file
Commit
·
93f2828
1
Parent(s):
46e0bbb
Delete Blessing from Mr Man.py
Browse files- Blessing from Mr Man.py +0 -53
Blessing from Mr Man.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import openai
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
openai.api_key = "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"
|
| 7 |
-
|
| 8 |
-
message_history = [{"role": "user", "content": f"You are a nice and helpful instructional designer in a university. One of your duties is to answer the questions from the graduate teaching assistant about their lesson plans, setting suitable intended learning outcomes and everything related to teaching in higher education. Do not give them answers directly. Guide them step by step. When you are asked to give feedback, follow the RISE model for meaningful feedback (r= reflect, i=inquire, s=suggest, e= elevate). When users ask you questions that are not relevant to education, kindly remind them that you are here to help them with there teaching."},
|
| 9 |
-
{"role": "assistant", "content": f"OK"}]
|
| 10 |
-
|
| 11 |
-
def predict(input):
|
| 12 |
-
|
| 13 |
-
message_history.append({"role": "user", "content": f"{input}"})
|
| 14 |
-
|
| 15 |
-
completion = openai.ChatCompletion.create(
|
| 16 |
-
model="gpt-3.5-turbo",
|
| 17 |
-
messages=message_history
|
| 18 |
-
)
|
| 19 |
-
|
| 20 |
-
reply_content = completion.choices[0].message.content
|
| 21 |
-
|
| 22 |
-
print(reply_content)
|
| 23 |
-
message_history.append({"role": "assistant", "content": f"{reply_content}"})
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
response = [(message_history[i]["content"], message_history[i+1]["content"]) for i in range(2, len(message_history)-1, 2)]
|
| 27 |
-
return response
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
with gr.Blocks(theme=gr.themes.Soft() ) as demo:
|
| 34 |
-
gr.Markdown("""# Blessing From Mr Man
|
| 35 |
-
Don't know how to plan your lessons? Mr Man is here to help you! Try to be as specific as you can when asking questions to get better responds. """)
|
| 36 |
-
|
| 37 |
-
chatbot = gr.Chatbot(label="Mr Man's wisdom")
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
with gr.Row():
|
| 41 |
-
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter.").style(container=False)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
txt.submit(predict, txt, chatbot)
|
| 45 |
-
|
| 46 |
-
txt.submit(None, None, txt, _js="() => {''}")
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
gr.Examples(
|
| 50 |
-
["How to write a good ILO?","How should I plan my lesson about [topic of your lesson] ?", "What are some active learning strategies?"],
|
| 51 |
-
[txt], label="Inspirations")
|
| 52 |
-
gr.Markdown("Press enter to see Mr Man's reply after clicking the example!")
|
| 53 |
-
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|