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.markdown("**Step 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("**Step 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("**Step 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("**Step 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("**Step 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("**Step 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): # ... def write_iep_assist(): st.title("IEP Assist Premium") # Select the student's grade level st.markdown("

Step 1: Select the student's grade level:

", 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("

Step 2: Select the student's qualifying condition(s):

", 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("

Step 3: Choose a category and prompt:

", 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("

Step 4: Enter student data to be analyzed:

", 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("Step 5: Generate IEP Goal", key="generate-goal") # Add a button to generate the analysis and IEP goal generate_button = st.button("Step 6: 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"

Effective IEP Goal:

{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"

Analysis:

{statement}", unsafe_allow_html=True) if __name__ == "__main__": write_sidebar() write_iep_assist()