test_space / app.py
rbuell's picture
Update app.py
f7374f9
raw
history blame
9.73 kB
import os
import openai
import streamlit as st
# Get API key from environment variable
api_key = os.environ.get("API_KEY")
if api_key is None:
raise ValueError("API_KEY environment variable not set")
# Set API key for OpenAI
openai.api_key = api_key
def write_sidebar():
st.sidebar.title("How to Use")
st.sidebar.markdown("**1. Select the student's grade level.**")
st.sidebar.markdown("Choose the grade level of the student you want to analyze.")
st.sidebar.markdown("---")
st.sidebar.markdown("**2. Select the student's qualifying condition(s).**")
st.sidebar.markdown("Select one or more qualifying conditions that apply to the student.")
st.sidebar.markdown("---")
st.sidebar.markdown("**3. Choose a category and prompt to analyze.**")
st.sidebar.markdown("Select the category that corresponds to the area you want to analyze (e.g., Reading, Writing). Then choose a specific prompt related to that category.")
st.sidebar.markdown("---")
st.sidebar.markdown("**4. Enter your student data.**")
st.sidebar.markdown("Paste the relevant data about the student that you want to analyze. Provide information such as assessments, performance data, or observations.")
st.sidebar.markdown("---")
st.sidebar.markdown("**5. Check the box to generate an IEP goal.**")
st.sidebar.markdown("If you want the tool to generate an IEP goal based on the analysis, check this box.")
st.sidebar.markdown("---")
st.sidebar.markdown("**6. Click the 'Generate' button to generate the selected output.**")
st.sidebar.markdown("Once you have filled in the necessary information, click the 'Generate' button to generate the analysis or analysis with an IEP goal, depending on your selection.")
st.sidebar.write("")
st.sidebar.write("")
st.sidebar.write("Note: This app uses OpenAI's GPT-3 API to generate the analysis and IEP goal. Please enter data that is relevant and appropriate for generating the output.")
def get_grade_specific_prompts(grade_level):
prompts = {
"Reading": [
"Analyze the reading data of a {grade} student to determine their current reading level and identify areas for growth. Provide insights into their reading fluency, comprehension, and decoding skills.",
"Based on the reading data of a {grade} student, summarize their reading strengths and weaknesses. Highlight specific areas that require support or intervention to enhance their overall reading abilities."
],
"Writing": [
"Analyze the writing samples and assessments of a {grade} student to assess their current writing skills. Identify their strengths and areas for improvement in areas such as organization, grammar, sentence structure, and content development.",
"Based on the writing data of a {grade} student, evaluate their written expression. Summarize their writing strengths and areas that need development. Suggest strategies to enhance their overall writing abilities."
],
"Math": [
"Analyze the math performance data of a {grade} student to assess their current math skills. Identify their strengths and areas for improvement in various mathematical concepts such as number sense, operations, geometry, and problem-solving.",
"Based on the math data of a {grade} student, evaluate their math abilities. Summarize their math strengths and areas that require additional support. Recommend strategies and interventions to foster their mathematical understanding and proficiency."
],
"Functional": [
"Review the functional skills data of a {grade} student to assess their current level of independence in daily living tasks. Identify their strengths and areas that require support or intervention in areas such as self-care, communication, social skills, and functional academics.",
"Based on the functional skills data of a {grade} student, evaluate their abilities in daily living tasks. Summarize their functional strengths and areas for improvement. Provide recommendations to enhance their independence and functional skills development."
],
"Speech": [
"Analyze the speech or language assessments of a {grade} student to assess their current communication abilities. Identify their speech or language strengths and areas for improvement in areas such as articulation, fluency, vocabulary, grammar, and pragmatic skills.",
"Based on the speech data of a {grade} student, evaluate their speech or language skills. Summarize their communication strengths and areas that require attention. Suggest interventions and strategies to support their speech or language development."
],
"Behavior": [
"Review the behavior data of a {grade} student to assess their current behavior patterns and identify factors influencing their behavior. Summarize their behavior strengths and areas for improvement. Recommend behavior management strategies or interventions to address their specific needs.",
"Based on the behavior data of a {grade} student, evaluate their behavior patterns and trends. Summarize their behavior strengths and areas that require support. Provide guidance on effective behavior management techniques and interventions."
],
"Other": [
"Analyze the data of a {grade} student in the specified area (e.g., social skills, executive functioning, sensory integration) to assess their current abilities. Identify their strengths and areas for growth. Provide insights and suggestions to support their development and success in the given domain.",
"Based on the data of a {grade} student in the specified area, evaluate their current abilities and areas that require attention. Summarize their strengths and areas for improvement. Recommend strategies, interventions, or accommodations to address their unique needs."
]
}
grade = grade_level if grade_level != "Pre-K" else "Pre-Kindergarten"
grade_specific_prompts = {category: [prompt.format(grade=grade) for prompt in prompts[category]] for category in prompts}
return grade_specific_prompts
def write_iep_assist():
st.title("IEP Assist Premium")
# Select the student's grade level
st.markdown("<h3>Select the student's grade level:</h3>", unsafe_allow_html=True)
grade_level = st.selectbox("Grade:", ["Pre-K", "K", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th"], key="grade-level")
# Select the student's qualifying condition
st.markdown("<h3>Select the student's qualifying condition(s):</h3>", unsafe_allow_html=True)
qualifying_condition = st.multiselect("Qualifying Condition(s):", ["Specific Learning Disability", "Emotional Disturbance", "Autism", "Intellectual Disability", "Speech/Language Impairment", "Other Health Impairment", "Orthopedic Impairment", "Auditory Impairment", "Traumatic Brain Injury", "Deafness", "Blindness", "Developmental Delay"], key="qualifying-condition")
grade_specific_prompts = get_grade_specific_prompts(grade_level)
# Choose a category and prompt
st.markdown("<h3>Choose a category and prompt:</h3>", unsafe_allow_html=True)
selected_category = st.selectbox("Category:", options=list(grade_specific_prompts.keys()), key="category")
prompts = grade_specific_prompts[selected_category]
selected_prompt = st.selectbox("Prompt:", options=prompts, key="prompt")
# Enter student data to be analyzed
st.markdown("<h3>Enter student data to be analyzed:</h3>", unsafe_allow_html=True)
student_data = st.text_area("Paste student data here", height=250, key="student-data")
# Checkbox to generate IEP goal
generate_goal = st.checkbox("Check box to generate an IEP Goal", key="generate-goal")
# Add a button to generate the analysis and IEP goal
generate_button = st.button("Generate", key="generate-button", help="Click here to generate the selected output.")
if generate_button:
if generate_goal:
# Call the OpenAI API and generate an effective IEP goal
response = openai.Completion.create(
engine="text-davinci-003",
prompt=f"Generate an effective and measurable IEP goal for a {grade_level} student with qualifying conditions of {', '.join(qualifying_condition)}. The goal should be based on the analysis of their data and meet the following characteristics: Measurable, Specific and Clear, Attainable and Realistic, Relevant and Meaningful, Time-Bound, Individualized, Action-Oriented, Aligned with Standards and Curriculum, Collaboratively Developed, Monitored and Adjusted. Data Analysis: {selected_prompt} {student_data}",
max_tokens=2000,
n=1,
stop=None,
temperature=0.85,
)
goal = response["choices"][0]["text"]
# Show the generated effective IEP goal
st.markdown(f"<h3>Effective IEP Goal:</h3>{goal}", unsafe_allow_html=True)
else:
# Call the OpenAI API and generate the analysis
response = openai.Completion.create(
engine="text-davinci-003",
prompt=f"{selected_prompt} {student_data} {grade_level} {qualifying_condition}",
max_tokens=2000,
n=1,
stop=None,
temperature=0.9,
)
statement = response["choices"][0]["text"]
# Show the generated analysis
st.markdown(f"<h3>Analysis:</h3>{statement}", unsafe_allow_html=True)
if __name__ == "__main__":
write_sidebar()
write_iep_assist()