Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import openai
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
# Get API key from environment variable
|
6 |
+
api_key = os.environ.get("API_KEY")
|
7 |
+
if api_key is None:
|
8 |
+
raise ValueError("API_KEY environment variable not set")
|
9 |
+
|
10 |
+
# Set API key for OpenAI
|
11 |
+
openai.api_key = api_key
|
12 |
+
|
13 |
+
# Add a sidebar with instructions
|
14 |
+
def write_sidebar():
|
15 |
+
st.sidebar.title("Instructions")
|
16 |
+
st.sidebar.write("1. Copy & paste or type in student data from your data collection forms.")
|
17 |
+
st.sidebar.write("2. Click the 'Analyze' button to generate a PLAAFP statement based on your inputted information.")
|
18 |
+
st.sidebar.write("3. Take the analysis from IEP Assist.")
|
19 |
+
|
20 |
+
st.sidebar.write("")
|
21 |
+
st.sidebar.write("")
|
22 |
+
|
23 |
+
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.")
|
24 |
+
|
25 |
+
def write_iep():
|
26 |
+
st.title("IEP Assist")
|
27 |
+
|
28 |
+
# Add a text area
|
29 |
+
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)
|
30 |
+
|
31 |
+
# Add a submit button
|
32 |
+
if st.button("Analyze"):
|
33 |
+
# Use OpenAI to generate IEP based on student
|
34 |
+
response = openai.Completion.create(
|
35 |
+
engine="text-davinci-003",
|
36 |
+
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,
|
37 |
+
max_tokens=2048,
|
38 |
+
n=1,
|
39 |
+
stop=None,
|
40 |
+
temperature=0.8
|
41 |
+
)
|
42 |
+
iep = response["choices"][0]["text"]
|
43 |
+
st.write(iep)
|
44 |
+
|
45 |
+
def main():
|
46 |
+
write_iep()
|
47 |
+
write_sidebar()
|
48 |
+
|
49 |
+
if __name__ == "__main__":
|
50 |
+
main()
|