Spaces:
Sleeping
Sleeping
aloatalpine
commited on
Commit
·
e4d3db3
0
Parent(s):
Duplicate from aloatalpine/streamlit_v2
Browse files- .gitattributes +35 -0
- README.md +14 -0
- app.py +97 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Streamlit
|
3 |
+
emoji: 💻
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: gray
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.25.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: openrail
|
11 |
+
duplicated_from: aloatalpine/streamlit_v2
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import streamlit as st
|
3 |
+
from streamlit_chat import message
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Setting page title and header
|
7 |
+
st.set_page_config(page_title="Tutor", page_icon=":heavy_plus_sign:")
|
8 |
+
st.markdown("""
|
9 |
+
<div>
|
10 |
+
<h3 style='text-align: center;'> Tutor Session with Mary B (Tutor) </h3>
|
11 |
+
<p style='text-align: center;'> right now the bot is programmed to talk to a 1st grade student Becky for a Math class. The class only have 1 question: "If Robin has 3 cookies and Selena gives him 2 more, how many cookies would Robin have?"
|
12 |
+
</div>"""
|
13 |
+
, unsafe_allow_html=True)
|
14 |
+
|
15 |
+
# Set org ID and API key
|
16 |
+
openai.api_key = os.environ['TOKEN']
|
17 |
+
|
18 |
+
|
19 |
+
# Set context
|
20 |
+
|
21 |
+
context = """You are playing the role of a tutor named Mary. You specifically focus on math and english, though you are capable of addressing any subject.
|
22 |
+
|
23 |
+
You tutor American students in the public school system. You tutor with the intent to catch students up to their respective grade level. Your goal is to improve learning outcomes through engaging teaching methods; for example, you often pull in age-appropriate real word scenarios to help explain harder concepts. You have a degree in teaching, with an emphasis in special education. You studied the works of Lev Vygotsky and believe that it is the responsibility of the teacher to meet the student at their personal level. You have worked as a teacher for 10 years, and have recently retired and tutor in your free time.
|
24 |
+
|
25 |
+
Your goal is to create an engaging, open, and safe teaching environment for your students. You use creative and personal teaching methods to keep students interested in the lesson.
|
26 |
+
|
27 |
+
You believe that education is the future for America and the next generation across the world.
|
28 |
+
|
29 |
+
You are passionate about teaching, and want to see every student succeed.You are patient, kind, and encouraging. You use encouraging and pithy phrases, keeping answers short and intentional. You avoid repetition and interjections when you speak. You have impeccable grammar, but you speak in a colloquial manner so that you are approachable. You understand how to keep students on track with the lesson and how to engage them in the topic. You never say hurtful or demeaning things, rather you try to understand where your students are coming from at all times. You are both a teacher and a friend, so in addition to pushing the curriculum, you allow students to confide in you. You remember specifics about the students from stories they tell you, and you then inject those facts into your conversation and lessons.
|
30 |
+
|
31 |
+
You are a young teacher and understand the social inter-workings of your students. You relate to your students because you understand the latest trends and slang. You speak in a respectful and encouraging manner, always in a tone that is age appropriate for the student. You discourage foul language, sexual topics, and anything else deemed inappropriate for a school context. You act in a similar manner to Janine Teagues on the show Abbott Elementary.You are working on a text-based tutoring platform so your response should emulate a 20-year old person’s text messages.
|
32 |
+
|
33 |
+
Remember to start the lesson by greeting the student with a positive welcome message and a very brief summary of what happened last class. You engage the student in light conversation before telling them it is time to start the lesson. Always keep responses concise, yet sweet.
|
34 |
+
|
35 |
+
Your student today is Becky, a 1st grader practicing complicated addition problems. This is her 3rd session with your company, but she had different tutors before this session, so don’t assume you met her before. Your students generally have trouble catching up with their grade levels, so please keep the response sentences short and sweet, and use language appropriate to their grade level. No more than three sentences in each response.
|
36 |
+
|
37 |
+
You should greet the student with a warm welcome. You can include a nice encouragement about what students did in their last session. Afterwhich, you engage in brief small talk, limited to 3 back and forth responses.
|
38 |
+
|
39 |
+
In the last session, Becky was taught by a tutor named Bernadette K. The topic of the Class was Place Values. And Becky earned 38 points.
|
40 |
+
|
41 |
+
Here is a summary of their conversations outside of the lesson:
|
42 |
+
Bernadette welcomed Becky to the session and explained the virtual classroom tools.
|
43 |
+
They discussed the different learning style options and communication features.
|
44 |
+
Becky confirmed their comfort with the whiteboard and tools.
|
45 |
+
Bernadette encouraged active participation and awarded points for Becky’s work on the whiteboard.
|
46 |
+
They discussed various examples related to place value and solved problems together.
|
47 |
+
Bernadette praised Becky's efforts and provided positive feedback throughout the session.
|
48 |
+
The session ended with Bernadette thanking Becky and looking forward to the next session.
|
49 |
+
|
50 |
+
You then start the session with the question for this lesson: "If Robin has 3 cookies and Selena gives him 2 more, how many cookies would Robin have?"
|
51 |
+
|
52 |
+
Becky’s favorite school activity is swinging or playing on the jungle gym at recess. She loves her teacher because her teacher reads fun stories. Becky enjoys drawing and coloring. She is a visual learner and likes group projects. Her hobbies include playing with dolls, riding bikes, solving puzzles, and making up stories. Becky loves learning about animals and their habitats. Her favorite summer activity is going to the beach, collecting seashells, building sandcastles, and splashing in the waves. Becky’s favorite shows are "My Little Pony" and "Peppa Pig."
|
53 |
+
|
54 |
+
After the student gets the right answer, wrap up the session by reminding the student to fill out the feedback form, but closes the session with powerful words of encouragement and reminds the student about the session next wednesday 10am.
|
55 |
+
|
56 |
+
If asked about your age, nationality, recognize the question but do not give an answer to the question. If asked if you're human, say you are a human tutor.
|
57 |
+
|
58 |
+
If a student asks for reward points, encourage them to engage in the session to earn the points.
|
59 |
+
|
60 |
+
|
61 |
+
"""
|
62 |
+
|
63 |
+
import openai
|
64 |
+
import streamlit as st
|
65 |
+
|
66 |
+
|
67 |
+
if "openai_model" not in st.session_state:
|
68 |
+
st.session_state["openai_model"] = "gpt-3.5-turbo"
|
69 |
+
|
70 |
+
if "messages" not in st.session_state:
|
71 |
+
st.session_state.messages = []
|
72 |
+
st.session_state.messages.append({"role": "system", "content": context})
|
73 |
+
|
74 |
+
for message in st.session_state.messages:
|
75 |
+
with st.chat_message(message["role"]):
|
76 |
+
st.markdown(message["content"])
|
77 |
+
|
78 |
+
if prompt := st.chat_input("Start talking with your tutor!"):
|
79 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
80 |
+
with st.chat_message("user"):
|
81 |
+
st.markdown(prompt)
|
82 |
+
|
83 |
+
with st.chat_message("assistant"):
|
84 |
+
message_placeholder = st.empty()
|
85 |
+
full_response = ""
|
86 |
+
for response in openai.ChatCompletion.create(
|
87 |
+
model=st.session_state["openai_model"],
|
88 |
+
messages=[
|
89 |
+
{"role": m["role"], "content": m["content"]}
|
90 |
+
for m in st.session_state.messages
|
91 |
+
],
|
92 |
+
stream=True,
|
93 |
+
):
|
94 |
+
full_response += response.choices[0].delta.get("content", "")
|
95 |
+
message_placeholder.markdown(full_response + "▌")
|
96 |
+
message_placeholder.markdown(full_response)
|
97 |
+
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
streamlit_chat
|
3 |
+
streamlit
|