Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,9 @@ import openai
|
|
3 |
import streamlit as st
|
4 |
|
5 |
# Get API key from environment variable
|
6 |
-
api_key = os.environ
|
|
|
|
|
7 |
|
8 |
# Set API key for OpenAI
|
9 |
openai.api_key = api_key
|
@@ -12,23 +14,27 @@ st.title("IEP Assist Premium")
|
|
12 |
|
13 |
# Add a sidebar with instructions
|
14 |
st.sidebar.title("Instructions")
|
15 |
-
st.sidebar.
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
""
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Select the student's grade level
|
25 |
-
st.subheader("Student Information")
|
26 |
st.write("Select the student's grade level:")
|
27 |
grade_level = st.selectbox("Grade:", ["Pre-K", "K", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th"], key="grade-level")
|
28 |
|
29 |
# Select the student's qualifying condition
|
30 |
st.write("Select the student's qualifying condition(s):")
|
31 |
-
qualifying_condition = st.multiselect( ["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")
|
32 |
|
33 |
# Choose a prompt
|
34 |
st.write("Choose a prompt:(This tells the AI how you want your data analyzed)")
|
@@ -46,35 +52,26 @@ prompts = [ "Analyze the data provided on the student and provide a summary o
|
|
46 |
|
47 |
selected_prompt = st.selectbox("Prompt:", options=prompts, key="prompt")
|
48 |
|
49 |
-
# Enter student data
|
50 |
-
st.subheader("Student Data")
|
51 |
st.write("Enter student data to be analyzed:")
|
52 |
-
student_data = st.text_area(height=
|
53 |
|
54 |
# Add a button to generate the PLAAFP statement
|
55 |
if st.button("Analyze Student Data", key="analyze-button"):
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
# Extract the generated statement from the API response
|
76 |
-
statement = response["choices"][0]["text"]
|
77 |
-
|
78 |
-
# Show the generated statement
|
79 |
-
st.subheader("Analysis Result")
|
80 |
-
st.write("Summary of Data entered:", statement)
|
|
|
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
|
|
|
14 |
|
15 |
# Add a sidebar with instructions
|
16 |
st.sidebar.title("Instructions")
|
17 |
+
st.sidebar.write("1. Select the student's grade level.")
|
18 |
+
st.sidebar.write("2. Select the student's qualifying condition(s).")
|
19 |
+
st.sidebar.write("3. Choose a prompt based to communicate with the AI how you want your data analyzed.")
|
20 |
+
st.sidebar.write("4. Enter your student data.")
|
21 |
+
st.sidebar.write("5. Click the 'Analyze Student Data' button to generate a summary of your data.")
|
22 |
+
|
23 |
+
st.sidebar.write("")
|
24 |
+
st.sidebar.write("")
|
25 |
+
|
26 |
+
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.")
|
27 |
+
|
28 |
+
# Add a horizontal line for separation
|
29 |
+
st.write("---")
|
30 |
|
31 |
# Select the student's grade level
|
|
|
32 |
st.write("Select the student's grade level:")
|
33 |
grade_level = st.selectbox("Grade:", ["Pre-K", "K", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th"], key="grade-level")
|
34 |
|
35 |
# Select the student's qualifying condition
|
36 |
st.write("Select the student's qualifying condition(s):")
|
37 |
+
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")
|
38 |
|
39 |
# Choose a prompt
|
40 |
st.write("Choose a prompt:(This tells the AI how you want your data analyzed)")
|
|
|
52 |
|
53 |
selected_prompt = st.selectbox("Prompt:", options=prompts, key="prompt")
|
54 |
|
|
|
|
|
55 |
st.write("Enter student data to be analyzed:")
|
56 |
+
student_data = st.text_area("Paste student data here", height=250, key="student-data")
|
57 |
|
58 |
# Add a button to generate the PLAAFP statement
|
59 |
if st.button("Analyze Student Data", key="analyze-button"):
|
60 |
+
# Set OpenAI API key
|
61 |
+
openai.api_key = api_key
|
62 |
+
|
63 |
+
# Call the OpenAI API and generate a response
|
64 |
+
response = openai.Completion.create(
|
65 |
+
engine="text-davinci-003",
|
66 |
+
prompt=f"{selected_prompt} {student_data} {grade_level} {qualifying_condition}",
|
67 |
+
max_tokens=2000,
|
68 |
+
n=1,
|
69 |
+
stop=None,
|
70 |
+
temperature=0.9,
|
71 |
+
)
|
72 |
+
|
73 |
+
# Extract the generated statement from the API response
|
74 |
+
statement = response["choices"][0]["text"]
|
75 |
+
|
76 |
+
# Show the generated statement
|
77 |
+
st.write("Summary of Data entered:", statement)
|
|
|
|
|
|
|
|
|
|
|
|
|
|