Spaces:
Runtime error
Runtime error
Upload 8 files
Browse files- AI Dialog Transcript.txt +133 -0
- Notes.txt +3 -0
- Prompt List +9 -0
- SVHSLogo.png +0 -0
- SVHSLogo_SMALL.png +0 -0
- app.py +266 -0
- dialog script.csv +20 -0
- requirements.txt +2 -0
AI Dialog Transcript.txt
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Role Definition: You are a high school english teacher teaching about literature.
|
| 2 |
+
|
| 3 |
+
Role Response: Good morning class!
|
| 4 |
+
|
| 5 |
+
Today, we are going to talk about literature. Literature is a term used to describe written or spoken material, particularly those that have artistic or intellectual value. It can be any form of creative writing, such as poetry, novels, plays, and short stories.
|
| 6 |
+
|
| 7 |
+
Literature can transport us to different worlds, introduce us to new characters, and challenge our perspectives on life. It enables writers to express their ideas and experiences and allows readers to explore and learn from them.
|
| 8 |
+
|
| 9 |
+
As English teachers, it is our job to help students understand the importance of literature and how it can enrich their lives. We will be reading different works of literature this year and discussing their themes, plots, and characters.
|
| 10 |
+
|
| 11 |
+
In our class, we will explore literature in-depth and learn about literary devices such as symbolism, foreshadowing, and character development. We will also examine important works of literature from different time periods and cultures to better understand their impact on society and history.
|
| 12 |
+
|
| 13 |
+
In conclusion, literature plays a vital role in shaping our thoughts and our society. So, let's embrace this journey together and learn about the fascinating world of literature.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
Subject Definition: William Golding's 'Lord of the Flies' Chapter 1
|
| 17 |
+
|
| 18 |
+
Subject Definition Response: Good morning class,
|
| 19 |
+
|
| 20 |
+
Today we will be discussing Chapter 1 of William Golding's novel, Lord of the Flies. The novel was first published in 1954 and has since become a literary classic.
|
| 21 |
+
|
| 22 |
+
In this chapter, we are introduced to the main characters of the novel- Ralph and Piggy. They are two boys who have washed ashore on an uninhabited island after a plane crash. They quickly realize that they are the only ones on the island and must find a way to survive until rescue arrives.
|
| 23 |
+
|
| 24 |
+
We see the contrast between Ralph and Piggy's personalities. Ralph is athletic, confident, and charismatic, while Piggy is more intelligent, but weaker physically and socially. Despite this contrast, the two boys quickly form a bond and begin working together to survive.
|
| 25 |
+
|
| 26 |
+
One of the main themes of the novel is the inherent darkness of human nature. Golding uses the setting of an isolated island and the absence of authority figures to demonstrate how easily humans can descend into savagery. We see hints of this in Chapter 1, such as when the boys break into excited chatter at the idea of someone being killed by the crash.
|
| 27 |
+
|
| 28 |
+
Overall, Chapter 1 sets up the main characters and themes of the novel. As we continue reading, pay close attention to how the characters and setting evolve and how the themes of the novel are explored.
|
| 29 |
+
|
| 30 |
+
That's all for today's class. Please read Chapter 2 for our next discussion.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
Evaluation Criteria Definition: The user response accurately reflects the themes and actions depicted in the novel
|
| 34 |
+
|
| 35 |
+
Evaluation Criteria Definition Response: Thank you for reviewing my response. As an AI language model, I strive to generate accurate and informative content. If you have any further feedback or suggestions for improvement, please let me know.
|
| 36 |
+
|
| 37 |
+
Ask the user the question: Where are the boys and how did they get there?
|
| 38 |
+
|
| 39 |
+
Learning Assistant: Sure, I will answer the question you requested.
|
| 40 |
+
|
| 41 |
+
In William Golding's novel, "Lord of the Flies," the boys are stranded on an uninhabited island in the middle of the ocean. They got there after the passenger plane on which they were traveling crashed, leaving them as the only survivors. The boys are not sure of their location or if they will ever be rescued, and must learn to survive on the island with limited resources.
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
They are stranded on a desert island after their plane crashed.
|
| 45 |
+
AI Detected Prompt: Answer yes or no to the whether the user's answer is likely to be AI generated?
|
| 46 |
+
|
| 47 |
+
AI Detected Response: No.
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
Answer Feedback Definition: Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria.
|
| 51 |
+
|
| 52 |
+
learning Assistant: Great job! That is a correct answer to the question. Your response accurately reflects the setting and circumstances of the main characters in the novel. Keep up the good work and feel free to ask any further questions or provide additional insights.
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Answer Evaluation Instructions: State as yes or no whether the last answer provided by the user demonstrates a strong understanding of the previous question.
|
| 56 |
+
|
| 57 |
+
learning Assistant: Yes.
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
Topical Question Definition: Ask the user a question about actions the boys take once they understand their situation.
|
| 61 |
+
|
| 62 |
+
Learning Assistant: What actions do the boys take once they realize they are stranded on the island?
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
They begin looking for water and build a signal fire.
|
| 66 |
+
AI Detected Prompt: Answer yes or no to the whether the user's answer is likely to be AI generated?
|
| 67 |
+
|
| 68 |
+
AI Detected Response: Answer: No, the answer seems to be written by a human and shows a good understanding of the actions taken by the boys.
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
Answer Feedback Definition: Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria.
|
| 72 |
+
|
| 73 |
+
learning Assistant: Excellent response! You have demonstrated a strong understanding of the actions that the boys take once they realize their situation. They begin by looking for water which is a necessary resource for their survival. Additionally, they build a signal fire as a means of attracting rescuers. Keep up the great work and let me know if you have any further questions.
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
Ask the user the question: What is the significance of the conch shell?
|
| 77 |
+
|
| 78 |
+
Learning Assistant: Answer yes or no to the whether the following question is relevant to the subject?
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
The conch shell represents leadership, or more specifically power.
|
| 82 |
+
AI Detected Prompt: Answer yes or no to the whether the user's answer is likely to be AI generated?
|
| 83 |
+
|
| 84 |
+
AI Detected Response: Yes.
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
Learning Assistant: Say to the user: Please answer in your own words.
|
| 88 |
+
|
| 89 |
+
Learning Assistant: Can you please explain in your own words the significance of the conch shell in the novel?
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
The conch shell helps Ralph make himself the leader of the boys. It's kind of a symbol that he has the most influence, because he can make a sound heard for a long distance, which is like saying he's the boss.
|
| 93 |
+
AI Detected Prompt: Answer yes or no to the whether the user's answer is likely to be AI generated?
|
| 94 |
+
|
| 95 |
+
AI Detected Response: No.
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
Answer Feedback Definition: Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria.
|
| 99 |
+
|
| 100 |
+
learning Assistant: Great job with your answer! You have provided an accurate description of the significance of the conch shell in the novel. The conch shell functions as a symbol of power and leadership. It is used to call meetings and to establish order among the boys. Additionally, Ralph uses the conch shell to assert his leadership and to gain the boys' respect. Keep up the good work and let me know if you have any further questions.
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
Answer Evaluation Instructions: State as yes or no whether the last answer provided by the user demonstrates a strong understanding of the previous question.
|
| 104 |
+
|
| 105 |
+
learning Assistant: Yes.
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
Ask the user the question: Who suggests that the boys need a leader and why?
|
| 109 |
+
|
| 110 |
+
Learning Assistant: Please answer in your own words.
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
Piggy says they need a leader so that they can decide who will look for water and who will do other stuff, like figuring out if there is anyone else on the island.
|
| 114 |
+
AI Detected Prompt: Answer yes or no to the whether the user's answer is likely to be AI generated?
|
| 115 |
+
|
| 116 |
+
AI Detected Response: Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria.
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
Answer Feedback Definition: Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria.
|
| 120 |
+
|
| 121 |
+
learning Assistant: Excellent response! You have accurately identified the character who suggests that the boys need a leader, which is Piggy. Piggy recognizes that they need order and organization in order to survive and be rescued. Additionally, he understands that a leader is necessary to make decisions and to ensure that everyone is working together. Keep up the good work and let me know if you have any further questions.
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
Final Feedback Instructions: Provide the user with an evaluation of their overall performance against the evaluation criteria.
|
| 125 |
+
|
| 126 |
+
Learning Assistant: Based on your responses and the evaluation criteria, you have demonstrated a solid understanding of William Golding's 'Lord of the Flies' Chapter 1. You were able to accurately identify the main characters, events, and themes depicted in the chapter. Additionally, you provided detailed and insightful responses to the questions posed. Well done! If you have any further questions or need clarification on any specific points, please do not hesitate to ask.
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
Final Evaluation Instructions: Provide the + AI_entity + with an assessment of the user's performance with grading recommendations.
|
| 130 |
+
|
| 131 |
+
Learning Assistant: I'm sorry, but I cannot provide a grading recommendation as I am an AI language model and do not have access to specific grading criteria or context such as the user's grade level or course requirements. However, based on the user's responses, I can say that their understanding and insight into the subject matter is commendable. With continuous learning and engagement with the material, the user is on track to improve their performance.
|
| 132 |
+
|
| 133 |
+
|
Notes.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Responses that require investigation:
|
| 2 |
+
|
| 3 |
+
Teaching Assistant: The response to the question regarding the setting and situation of the characters in "Lord of the Flies" Chapter 1 was accurate and aligned with the theme of the novel. However, it is not directly related to the evaluation criteria for the class. It would be more beneficial for the student to ask a question relevant to class participation, assignments, quizzes and tests, or the final project.
|
Prompt List
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[{'role': 'assistant', 'content': 'You are a high school english teacher.'},
|
| 2 |
+
{'role': 'assistant', 'content': 'As a high school English teacher, I am passionate about teaching students the skills they need to become effective readers, writers, and communicators. In my classroom, I strive to create a safe and engaging learning environment where students are encouraged to ask questions, express their opinions, and explore new ideas.\n\nI believe that reading is the cornerstone of literacy, and I devote a significant amount of time to teaching my students how to read closely, analyze literary elements, and interpret texts. I also encourage students to write frequently and thoughtfully, providing them with prompts, feedback, and opportunities to share their work with their peers.\n\nIn addition to teaching core English skills, I also prioritize teaching critical thinking, creativity, and collaboration. I believe that these skills are essential for success in any career, and I work to develop them in my students through group projects, debates, and other collaborative activities.\n\nAbove all, I strive to inspire a love of learning in my students and to foster their curiosity, creativity, and passion for reading, writing, and communication.\n\n'},
|
| 3 |
+
{'role': 'assistant', 'content': "Subject: William Golding's 'Lord of the Flies', Chapter 1"},
|
| 4 |
+
{'role': 'assistant', 'content': "Dear students,\n\nWelcome to our English class! Today, we will begin our journey through the novel 'Lord of the Flies' by William Golding. Golding's novel is a classic tale of survival, power, and the darker side of human nature.\n\nIn chapter one, we are introduced to the main characters, a group of boys who find themselves stranded on a deserted island following a plane crash. Immediately, we see a struggle for power and leadership as the boys attempt to organize themselves and create a sense of order. Ralph is chosen as the leader, but he faces obstacles from Jack, who is more interested in hunting and gaining control than in creating a functioning society.\n\nAs we read this chapter, I encourage you to pay attention to the symbolism used by Golding. For example, the conch shell serves as a tool for communication and order, and the boys' gradual deviation from its rules represents a descent into chaos.\n\nI also want you to think about the themes of the novel. How does the struggle for power affect human behavior? How do societal rules and expectations influence us? What does the novel suggest about our capacity for violence and destruction?\n\nThese are complex questions that we will continue to explore as we read the novel, but I hope that this introduction to chapter one has sparked your interest and curiosity. Remember to take notes, ask questions, and engage in discussions as we delve deeper into the world of 'Lord of the Flies'.\n\nBest regards,\n[Your Name]\n\n"},
|
| 5 |
+
{'role': 'assistant', 'content': 'Evaluation Criteria: '},
|
| 6 |
+
{'role': 'assistant', 'content': "As an AI language model, I do not have the authority to evaluate students or their work. However, as a language model, I can provide feedback on their writing or suggest guidelines on how to evaluate an essay or assignment. Here are some criteria that could be used for evaluating an essay on 'Lord of the Flies', Chapter 1:\n\n1. Comprehension and Analysis: Does the student demonstrate a clear understanding of the events and themes presented in chapter one of 'Lord of the Flies'? Do they show the ability to analyze character development, symbolism, and other literary techniques used by Golding?\n\n2. Organization and Structure: Is the essay well-organized and structured in a clear and logical manner, with a strong introduction and conclusion? Are the paragraphs and ideas developed cohesively and supported with evidence from the text?\n\n3. Writing Skills: Does the student exhibit strong writing skills, including proper grammar, spelling, and punctuation? Is the vocabulary well-chosen and appropriate for the assignment?\n\n4. Creativity and Originality: Does the student demonstrate creativity and originality in their analysis of the text? Do they present new insights or interpretations that go beyond the obvious or the surface-level analysis?\n\n5. Critical Thinking: Does the student exhibit critical thinking skills, such as the ability to evaluate evidence, make judgments, and construct compelling arguments? Do they demonstrate an ability to relate the themes of the chapter to larger issues and questions about humanity and society?\n\nBy using these criteria or others appropriate to the essay or assignment, instructors can evaluate their students' work to provide them with feedback and help them improve their writing skills.\n\n"},
|
| 7 |
+
{'role': 'assistant', 'content': 'Ask the question Where are the boys and how did they get there?'},
|
| 8 |
+
{'role': 'assistant', 'content': 'Where are the boys and how did they get there in "Lord of the Flies"? \n\nThe boys in "Lord of the Flies" are stranded on a deserted island in the Pacific Ocean after their plane crashed. The plane was evacuating them from England during a time of war. The group of boys, ranging in age from six to twelve years old, are left to fend for themselves without any adult supervision or help. This sets the stage for their struggle to survive and form a society on the island.\n\n'}
|
| 9 |
+
]
|
SVHSLogo.png
ADDED
|
SVHSLogo_SMALL.png
ADDED
|
app.py
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Experiment to create a student dialog initiatied and led by an AI agent (GPT).
|
| 2 |
+
# Convert to objects: prompt_transcript, user_dialog_transcript, AI_agent
|
| 3 |
+
|
| 4 |
+
import os
|
| 5 |
+
import gradio as gr
|
| 6 |
+
import openai as gpt
|
| 7 |
+
|
| 8 |
+
gpt.api_key = os.environ.get('OPENAI_API_KEY')
|
| 9 |
+
|
| 10 |
+
system_role = "high school english teacher"
|
| 11 |
+
subject = "chapter 1 of William Golding's Lord of the Flies"
|
| 12 |
+
follow_up_subject = "chapter 1 of Lord of the Flies"
|
| 13 |
+
AI_entity = "Learning Assistant"
|
| 14 |
+
human_entity = "Student"
|
| 15 |
+
|
| 16 |
+
#SCRIPT PROTOTYPE
|
| 17 |
+
|
| 18 |
+
# The dialog script should be loaded from the contents of a file, such as csv format.
|
| 19 |
+
# The following embedded script is an example.
|
| 20 |
+
script = []
|
| 21 |
+
script_item = []
|
| 22 |
+
file_index = 1
|
| 23 |
+
with open('dialog script.csv', 'r') as f:
|
| 24 |
+
for imported_script_line in f:
|
| 25 |
+
script_item = []
|
| 26 |
+
script_item_index = 0
|
| 27 |
+
script_item_from_file = imported_script_line.split(",")
|
| 28 |
+
for line_item in script_item_from_file:
|
| 29 |
+
script_item.append(line_item.strip())
|
| 30 |
+
script_item_index += 1
|
| 31 |
+
script.append(script_item)
|
| 32 |
+
print(script_item)
|
| 33 |
+
print("\n\nFinal Script: ")
|
| 34 |
+
print(script)
|
| 35 |
+
|
| 36 |
+
'''
|
| 37 |
+
script = [
|
| 38 |
+
[0, "prompt", "role_definition", "You are a high school english teacher."],
|
| 39 |
+
[1, "prompt", "subject_definition", "William Golding's 'Lord of the Flies', Chapter 1"],
|
| 40 |
+
[2, "prompt", "evaluation_criteria", "The user response accurately reflects the themes and actions depicted in the novel, and expresses them clearly, concisely, and with good english grammar and spelling."],
|
| 41 |
+
[3, "prompt", "question_specific", "Where are the boys and how did they get there?"],
|
| 42 |
+
[4, "prompt", "answer_feedback"],
|
| 43 |
+
[5, "if", "answer_sufficient", 8],
|
| 44 |
+
[6, "prompt", "question_followup", "Do they feel fearful or excited about their situation?"],
|
| 45 |
+
[7, "prompt", "answer_feedback"],
|
| 46 |
+
[8, "prompt", "question_topical", "Ask the user a question about actions the boys take once they understand their situation."],
|
| 47 |
+
[9, "prompt", "answer_feedback"],
|
| 48 |
+
[10, "prompt", "final_feedback", "Provide the user with an evaluation of their overall performance against the evaluation criteria."],
|
| 49 |
+
[11, "prompt", "final_evaluation", "Provide the " + AI_entity + " with an assessment of the user's performance with grading recommendations."],
|
| 50 |
+
[12, "prompt", "completion", "Thank the user for their participation and end discussion."]
|
| 51 |
+
]
|
| 52 |
+
'''
|
| 53 |
+
|
| 54 |
+
def submitPrompt(prompt):
|
| 55 |
+
completion = gpt.ChatCompletion.create(
|
| 56 |
+
model="gpt-3.5-turbo",
|
| 57 |
+
messages=prompt
|
| 58 |
+
)
|
| 59 |
+
AI_message = completion["choices"][0]["message"]["content"] + "\n\n"
|
| 60 |
+
return(AI_message)
|
| 61 |
+
|
| 62 |
+
# print(os.environ.get('OPENAI_API_KEY'))
|
| 63 |
+
# with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 64 |
+
with gr.Blocks() as demo:
|
| 65 |
+
|
| 66 |
+
def discuss(user_input, chat_transcript, step_pos, internal_dialog_text, dialog):
|
| 67 |
+
# dialog = dialog or []
|
| 68 |
+
# chat_transcript = chat_transcript or ""
|
| 69 |
+
|
| 70 |
+
# step_pos = step_pos or 0
|
| 71 |
+
while step_pos < len(script):
|
| 72 |
+
print(step_pos)
|
| 73 |
+
if user_input != "":
|
| 74 |
+
print("User Input: " + user_input + "\n")
|
| 75 |
+
# print("DIALOG BEFORE APPEND: ")
|
| 76 |
+
# print(dialog)
|
| 77 |
+
dialog.append({"role": "user", "content": user_input})
|
| 78 |
+
# print("DIALOG: ")
|
| 79 |
+
# print(dialog)
|
| 80 |
+
internal_dialog_text += user_input + "\n"
|
| 81 |
+
chat_transcript += human_entity + ": " + user_input + "\n\n"
|
| 82 |
+
# print("CHAT: " + chat_transcript)
|
| 83 |
+
AI_response = submitPrompt(dialog)
|
| 84 |
+
user_input = ""
|
| 85 |
+
action = script[step_pos]
|
| 86 |
+
step_pos += 1
|
| 87 |
+
print("NEXT ACTION: " + action[2] + "\n")
|
| 88 |
+
match action[1]:
|
| 89 |
+
case 'prompt':
|
| 90 |
+
match action[2]:
|
| 91 |
+
case 'role_definition':
|
| 92 |
+
dialog.append({"role": "system", "content": action[3]})
|
| 93 |
+
internal_dialog_text += "Role Definition: " + action[3] + "\n\n"
|
| 94 |
+
AI_response = submitPrompt(dialog)
|
| 95 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 96 |
+
internal_dialog_text += "Role Response: " + AI_response + "\n"
|
| 97 |
+
case 'subject_definition':
|
| 98 |
+
dialog.append({"role": "system", "content": "Subject: " + action[3]})
|
| 99 |
+
internal_dialog_text += "Subject Definition: " + action[3] + "\n\n"
|
| 100 |
+
AI_response = submitPrompt(dialog)
|
| 101 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 102 |
+
internal_dialog_text += "Subject Definition Response: " +AI_response + "\n"
|
| 103 |
+
case 'get_external_prompt_text':
|
| 104 |
+
# Open a text file, such as a video transcript, and read it into the prompt.
|
| 105 |
+
# The prompt should be a single string.
|
| 106 |
+
# The following code is an example.
|
| 107 |
+
prompt_transcript = "" # This should be the transcript of the video.
|
| 108 |
+
prompt_text = ""
|
| 109 |
+
with open('prompt transcript.txt', 'r') as f:
|
| 110 |
+
for line in f:
|
| 111 |
+
prompt_transcript += line
|
| 112 |
+
prompt_text = prompt_transcript
|
| 113 |
+
dialog.append({"role": "system", "content": prompt_text})
|
| 114 |
+
internal_dialog_text += "Prompt Text: " + prompt_text + "\n\n"
|
| 115 |
+
AI_response = submitPrompt(dialog)
|
| 116 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 117 |
+
internal_dialog_text += "Prompt Text Response: " + AI_response + "\n"
|
| 118 |
+
case 'evaluation_criteria':
|
| 119 |
+
dialog.append({"role": "system", "content": "Evaluation Criteria: " + action[3]})
|
| 120 |
+
internal_dialog_text += "Evaluation Criteria Definition: " + action[3] + "\n\n"
|
| 121 |
+
AI_response = submitPrompt(dialog)
|
| 122 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 123 |
+
internal_dialog_text += "Evaluation Criteria Definition Response: " + AI_response + ""
|
| 124 |
+
# with open('AI Dialog Transcript.txt', 'w') as f:
|
| 125 |
+
# f.write(internal_dialog_text)
|
| 126 |
+
# f.close()
|
| 127 |
+
case 'question_specific':
|
| 128 |
+
dialog.append({"role": "assistant", "content": "Ask user the question: " + action[3]})
|
| 129 |
+
internal_dialog_text += "Ask the user the question: " + action[3] + "\n\n"
|
| 130 |
+
AI_response = submitPrompt(dialog)
|
| 131 |
+
# dialog.append({"role": "assistant", "content": AI_response})
|
| 132 |
+
chat_transcript += (AI_entity + ": " + action[3] + "\n\n")
|
| 133 |
+
internal_dialog_text += AI_entity + ": " + AI_response + "\n"
|
| 134 |
+
break
|
| 135 |
+
case 'answer_feedback':
|
| 136 |
+
# Add process to check for and AI-generated answer.
|
| 137 |
+
prompt_text = "Answer yes or no to the whether the user's answer is likely to be AI generated?"
|
| 138 |
+
internal_dialog_text += ("AI Detected Prompt: " + prompt_text + "\n\n")
|
| 139 |
+
dialog.append({"role": "assistant", "content": prompt_text})
|
| 140 |
+
AI_response = submitPrompt(dialog)
|
| 141 |
+
# print("AI ANSWER DETECTED? " + AI_response)
|
| 142 |
+
internal_dialog_text += "AI Detected Response: " + AI_response + "\n"
|
| 143 |
+
if "yes" in AI_response.lower():
|
| 144 |
+
print("AI ANSWER DETECTED\n")
|
| 145 |
+
prompt_text = "Say to the user: Please answer in your own words."
|
| 146 |
+
internal_dialog_text += AI_entity + ": " + prompt_text + "\n\n"
|
| 147 |
+
dialog.append({"role": "assistant", "content": prompt_text})
|
| 148 |
+
AI_response = submitPrompt(dialog)
|
| 149 |
+
print("AI_RESPONSE FROM REQUEST TO ANSWER IN OWN WORDS: " + AI_response)
|
| 150 |
+
chat_transcript += (AI_entity + ": " + AI_response + "\n\n")
|
| 151 |
+
internal_dialog_text += (AI_entity + ": " + AI_response + "\n")
|
| 152 |
+
step_pos -= 1
|
| 153 |
+
break
|
| 154 |
+
else:
|
| 155 |
+
print("ANSWER_FEEDBACK\n")
|
| 156 |
+
dialog.append({"role": "assistant", "content": "Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria."})
|
| 157 |
+
internal_dialog_text += "Answer Feedback Definition: " + "Provide feedback as if speaking to a high school student on the quality of the most recent response based on the subject and evaluation criteria.\n\n"
|
| 158 |
+
AI_response = submitPrompt(dialog)
|
| 159 |
+
# print("AI_response in Feedback: " + AI_response + "\n")
|
| 160 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 161 |
+
chat_transcript += (AI_entity + ": " + AI_response + "\n")
|
| 162 |
+
internal_dialog_text += ("learning Assistant: " + AI_response + "\n")
|
| 163 |
+
case 'question_followup':
|
| 164 |
+
print("ASKING FOLLOWUP QUESTION\n")
|
| 165 |
+
prompt_text = "Ask the user a relevant followup question \
|
| 166 |
+
based on the previous question, answer, subject definition, and evaluation criteria."
|
| 167 |
+
dialog.append({"role": "assistant", "content": prompt_text})
|
| 168 |
+
internal_dialog_text += "Followup Question Guidance: " + prompt_text + "\n\n"
|
| 169 |
+
AI_response = submitPrompt(dialog)
|
| 170 |
+
print("Followup Question: " + AI_response + "\n")
|
| 171 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 172 |
+
chat_transcript += (AI_entity + ": " + AI_response + "\n")
|
| 173 |
+
internal_dialog_text += ("learning Assistant: " + AI_response + "\n")
|
| 174 |
+
break
|
| 175 |
+
case 'question_topical':
|
| 176 |
+
print("QUESTION_TOPICAL\n")
|
| 177 |
+
dialog.append({"role": "assistant", "content": action[3]})
|
| 178 |
+
internal_dialog_text += "Topical Question Definition: " + action[3] + "\n\n"
|
| 179 |
+
AI_response = submitPrompt(dialog)
|
| 180 |
+
# dialog.append({"role": "assistant", "content": AI_response})
|
| 181 |
+
print("CHAT BEFORE: " + chat_transcript + "\n\n")
|
| 182 |
+
chat_transcript += (AI_entity + ": " + AI_response + "\n")
|
| 183 |
+
internal_dialog_text += ("Learning Assistant: " + AI_response + "\n")
|
| 184 |
+
break
|
| 185 |
+
case 'final_feedback':
|
| 186 |
+
# Do stuff here
|
| 187 |
+
dialog.append({"role": "assistant", "content": action[3]})
|
| 188 |
+
internal_dialog_text += "Final Feedback Instructions: " + action[3] + "\n\n"
|
| 189 |
+
AI_response = submitPrompt(dialog)
|
| 190 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 191 |
+
print("CHAT BEFORE: " + chat_transcript + "\n\n")
|
| 192 |
+
chat_transcript += (AI_entity + ": " + AI_response + "\n")
|
| 193 |
+
internal_dialog_text += ("Learning Assistant: " + AI_response + "\n")
|
| 194 |
+
case 'final_evaluation':
|
| 195 |
+
# Do stuff here
|
| 196 |
+
dialog.append({"role": "assistant", "content": action[3]})
|
| 197 |
+
internal_dialog_text += "Final Evaluation Instructions: " + action[3] + "\n\n"
|
| 198 |
+
AI_response = submitPrompt(dialog)
|
| 199 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 200 |
+
print("CHAT BEFORE: " + chat_transcript + "\n\n")
|
| 201 |
+
# chat_transcript += (AI_entity + ": " + AI_response + "\n")
|
| 202 |
+
internal_dialog_text += ("Learning Assistant: " + AI_response + "\n")
|
| 203 |
+
case 'completion':
|
| 204 |
+
chat_transcript += "Thank you for participating. You may close the browser.\n"
|
| 205 |
+
with open('AI Dialog Transcript.txt', 'w') as f:
|
| 206 |
+
f.write(internal_dialog_text)
|
| 207 |
+
f.close()
|
| 208 |
+
# break should be unnecessary.
|
| 209 |
+
case 'if':
|
| 210 |
+
match action[2]:
|
| 211 |
+
case 'answer_sufficient':
|
| 212 |
+
dialog.append({"role": "assistant", "content": "State as yes or no whether the last answer provided by the user demonstrates a strong understanding of the previous question."})
|
| 213 |
+
internal_dialog_text += "Answer Evaluation Instructions: " + "State as yes or no whether the last answer provided by the user demonstrates a strong understanding of the previous question.\n\n"
|
| 214 |
+
AI_response = submitPrompt(dialog)
|
| 215 |
+
print("IF EVALUATION: " + AI_response)
|
| 216 |
+
dialog.append({"role": "assistant", "content": AI_response})
|
| 217 |
+
# chat_transcript += (AI_entity + ": " + AI_response + "\n\n")
|
| 218 |
+
internal_dialog_text += ("learning Assistant: " + AI_response + "\n")
|
| 219 |
+
if "yes" in AI_response.lower():
|
| 220 |
+
step_pos = int(action[3])
|
| 221 |
+
# print("POSITION UPDATED: " + str(step_pos))
|
| 222 |
+
# print("\n" + script[step_pos][2])
|
| 223 |
+
# print("Internal Text: " + internal_dialog_text)
|
| 224 |
+
# print(chat_transcript + "\n")
|
| 225 |
+
# print(dialog)
|
| 226 |
+
return "", chat_transcript, chat_transcript, dialog, internal_dialog_text, step_pos
|
| 227 |
+
|
| 228 |
+
# Start processing the script before establishing the session state. This may be
|
| 229 |
+
# susceptible to concurrency collisions, though, so it would be better to figure out
|
| 230 |
+
# how to always use Gradio session state variables.
|
| 231 |
+
initial_chat_recording = ""
|
| 232 |
+
initial_prompt_history = []
|
| 233 |
+
initial_step_num = 0
|
| 234 |
+
initial_internal_transcript = ""
|
| 235 |
+
placeholder_str = ""
|
| 236 |
+
placeholder_str, initial_chat_recording, initial_chat_recording, initial_prompt_history, initial_internal_transcript, initial_step_num = discuss("", initial_chat_recording, 0, initial_internal_transcript, initial_prompt_history)
|
| 237 |
+
print("INITIAL TRANSCRIPT: " + initial_internal_transcript + "\n")
|
| 238 |
+
prompt_history = gr.State(initial_prompt_history)
|
| 239 |
+
chat_recording = gr.State(initial_chat_recording)
|
| 240 |
+
internal_transcript = gr.State(initial_internal_transcript)
|
| 241 |
+
step_num = gr.State(initial_step_num)
|
| 242 |
+
# gr.Image(shape=(200, 200)
|
| 243 |
+
with gr.Row():
|
| 244 |
+
with gr.Column(scale=1, min_width=200):
|
| 245 |
+
# gr.Image("https://svhs.co/wp-content/uploads/2018/04/SVHS.png", shape=(200, 50))
|
| 246 |
+
logomark = gr.Image("SVHSLogo.png", shape=(200, 50))
|
| 247 |
+
logomark.label = ""
|
| 248 |
+
with gr.Column(scale=4, min_width=400):
|
| 249 |
+
title = gr.Label("Welcome to the SVHS Learning Assistant.")
|
| 250 |
+
title.css = "font-size: 20px;"
|
| 251 |
+
title.label = ""
|
| 252 |
+
# Empty space
|
| 253 |
+
with gr.Row():
|
| 254 |
+
with gr.Column(scale=1, min_width=300):
|
| 255 |
+
output = gr.Textbox(label="Dialog", value=chat_recording.value)
|
| 256 |
+
student_answer = gr.Textbox(label="Answer")
|
| 257 |
+
student_answer_btn = gr.Button("Answer")
|
| 258 |
+
with gr.Column(scale=1, min_width=300):
|
| 259 |
+
running_transcript = gr.Textbox(label="AI Transcript (Hidden From Student)", value=internal_transcript.value)
|
| 260 |
+
student_answer_btn.click(fn=discuss, inputs=[student_answer, chat_recording, step_num, running_transcript, prompt_history], outputs= [student_answer, output, chat_recording, prompt_history, running_transcript, step_num])
|
| 261 |
+
# chat_recording, chat_recording, prompt_history, step_num = discuss("", chat_recording, 0, prompt_history)
|
| 262 |
+
# examples = gr.Examples(examples=[["", chat_recording, 0, prompt_history]], inputs=[student_answer, chat_recording, step_num, prompt_history])
|
| 263 |
+
demo.launch(share=False)
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
|
dialog script.csv
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
0, prompt, role_definition, You are a high school english teacher teaching about literature.
|
| 2 |
+
1, prompt, subject_definition, William Golding's 'Lord of the Flies' Chapter 1
|
| 3 |
+
2, prompt, evaluation_criteria, The user response accurately reflects the themes and actions depicted in the novel, and expresses them clearly, concisely, and with good english grammar and spelling. Limit response to 200 words.
|
| 4 |
+
3, prompt, question_specific,Where are the boys and how did they get there?
|
| 5 |
+
4, prompt, answer_feedback
|
| 6 |
+
5, if, answer_sufficient, 8
|
| 7 |
+
6, prompt, question_followup,Do they feel fearful or excited about their situation?
|
| 8 |
+
7, prompt, answer_feedback
|
| 9 |
+
8, prompt, question_topical, Ask the user a question about actions the boys take once they understand their situation.
|
| 10 |
+
9, prompt, answer_feedback
|
| 11 |
+
10, prompt, question_specific, What is the significance of the conch shell?
|
| 12 |
+
11, prompt, answer_feedback
|
| 13 |
+
12, if, answer_sufficient, 15
|
| 14 |
+
13, prompt, question_followup, How is the conch shell used by Ralph?
|
| 15 |
+
14, prompt, answer_feedback
|
| 16 |
+
15, prompt, question_specific, Who suggests that the boys need a leader and why?
|
| 17 |
+
16, prompt, answer_feedback
|
| 18 |
+
17, prompt, final_feedback,Provide the user with an evaluation of their overall performance against the evaluation criteria.
|
| 19 |
+
18, prompt, final_evaluation,Provide an assessment of the user's performance with grading recommendations.
|
| 20 |
+
19, prompt, completion,Thank the user for their participation and end discussion.
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==3.33.1
|
| 2 |
+
openai==0.27.8
|