test_space / app.py
rbuell's picture
Update app.py
284139b
raw
history blame
6.02 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("Instructions")
st.sidebar.write("1. Select the student's grade level.")
st.sidebar.write("2. Select the student's qualifying condition(s).")
st.sidebar.write("3. Choose a category to analyze.")
st.sidebar.write("4. Select whether you want to generate a PLAAFP statement or an effective IEP goal.")
st.sidebar.write("5. Enter your student data.")
st.sidebar.write("6. Click the 'Generate' button to generate the selected output.")
st.sidebar.write("")
st.sidebar.write("")
st.sidebar.write("Note: This app uses OpenAI's GPT-3 API to generate the PLAAFP statement or IEP goal. Please enter data that is relevant and appropriate for generating the output.")
def write_iep_assist():
st.title("IEP Assist Premium")
# Select the student's grade level
st.write("Select the student's grade level:")
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.write("Select the student's qualifying condition(s):")
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")
# Define prompts by category
prompt_categories = {
"Behavior": [
"Provide a summary of the student's behavior data and suggest possible interventions to try based on their areas of need.",
"Analyze the student's behavior data to identify trends and suggest possible interventions.",
"Provide a summary of the student's progress towards their behavioral goals."
],
"Academic": [
"Analyze the data provided on the student and provide a summary of their strengths and areas of need in regards to their academic performance.",
"Summarize the data provided on the student's academic performance, highlighting their strengths and areas of need, and suggesting possible interventions to try.",
"Please provide a summary of the student's academic performance, highlighting their strengths and areas of need.",
"What is the student's biggest strength and area of need in regards to their academic performance?",
"Based on the student's academic performance data, what recommendations do you have for adjusting their instructional strategies?",
"How can the student's strengths be leveraged to help them improve in areas of need?",
"What barriers to academic success does the student face, and how can they be addressed?"
],
"IEP Goals": [
"Analyze the data provided on the student and provide a summary of their progress in regards to their IEP goals.",
"Provide a summary of the student's progress towards their academic and behavioral goals."
]
}
# Choose a category
st.write("Choose a category to analyze:")
selected_category = st.selectbox("Category:", options=list(prompt_categories.keys()), key="category")
# Choose the output type
generate_goal = st.checkbox("Generate Effective IEP Goal")
# Choose a prompt from the selected category
st.write("Choose a prompt:")
prompts = prompt_categories[selected_category]
selected_prompt = st.selectbox("Prompt:", options=prompts, key="prompt")
# Enter student data to be analyzed
st.write("Enter student data to be analyzed:")
student_data = st.text_area("Paste student data here", height=250, key="student-data")
# Add a button to generate the PLAAFP statement or effective IEP goal
if st.button("Generate", key="generate-button"):
if generate_goal:
# Define the characteristics of an effective IEP goal
effective_goal_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"
# 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 student who is in grade {grade_level} and has qualifying conditions of {', '.join(qualifying_condition)}. The goal should be based on the analysis of their data and meet the following characteristics: {effective_goal_characteristics}. 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.write("Effective IEP Goal:", goal)
else:
# Call the OpenAI API and generate a PLAAFP statement
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 PLAAFP statement
st.write("Summary of Data entered:", statement)
if __name__ == "__main__":
write_sidebar()
write_iep_assist()