IEP_Assist / app.py
rbuell's picture
Create app.py
118c80d
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
# Add a sidebar with instructions
def write_sidebar():
st.sidebar.title("Instructions")
st.sidebar.write("1. Copy & paste or type in student data from your data collection forms.")
st.sidebar.write("2. Click the 'Analyze' button to generate a PLAAFP statement based on your inputted information.")
st.sidebar.write("3. Take the analysis from IEP Assist.")
st.sidebar.write("")
st.sidebar.write("")
st.sidebar.write("Note: This app uses OpenAI's GPT-3 API to generate the PLAAFP statement. Please enter data that is relevant and appropriate for generating the statement.")
def write_iep():
st.title("IEP Assist")
# Add a text area
user_query = st.text_area("Enter student data (ie. academic, functional, behavioral). To ensure that the generated PLAAFP statement accurately reflects the student's needs and abilities, it is important to provide as much relevant information as possible:", height=250)
# Add a submit button
if st.button("Analyze"):
# Use OpenAI to generate IEP based on student
response = openai.Completion.create(
engine="text-davinci-003",
prompt= "You are a special education case manager, the following data has been collected. Analyze and summarize this data into a cohesive PLAAFP statement, make it clear and concise and provide areas of strength and areas of need and strageties to improve areas of need: \n" + user_query,
max_tokens=2048,
n=1,
stop=None,
temperature=0.8
)
iep = response["choices"][0]["text"]
st.write(iep)
def main():
write_iep()
write_sidebar()
if __name__ == "__main__":
main()