Spaces:
Runtime error
Runtime error
Vipul Swarup commited on
Commit ·
65dc236
1
Parent(s): 3b226aa
JSON Input
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
# It takes as input: (1) The common core standard to use, (2) The area of interest
|
| 4 |
|
| 5 |
import streamlit as st
|
| 6 |
-
|
| 7 |
|
| 8 |
from langchain.chat_models import ChatOpenAI
|
| 9 |
from langchain.schema import (
|
|
@@ -20,7 +20,11 @@ st.header("FRQs using GPT-4")
|
|
| 20 |
|
| 21 |
if "sessionMessages" not in st.session_state:
|
| 22 |
st.session_state.sessionMessages = [
|
| 23 |
-
SystemMessage(content = "You are a bot that generates free response questions based on the input of a Common Core Standard, and area of interest.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
]
|
| 25 |
|
| 26 |
|
|
@@ -34,18 +38,21 @@ def load_answer(question):
|
|
| 34 |
|
| 35 |
#Gets the user input
|
| 36 |
def get_text():
|
| 37 |
-
input_text = st.text_area("Paste a JSON file here, with the following keys:
|
| 38 |
return input_text
|
| 39 |
|
| 40 |
chat = ChatOpenAI(temperature=0, model_name="gpt-4")
|
| 41 |
|
| 42 |
-
user_input=get_text()
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
submit = st.button('Generate')
|
| 46 |
|
| 47 |
#If generate button is clicked
|
| 48 |
if submit:
|
|
|
|
|
|
|
| 49 |
response = load_answer(user_input)
|
| 50 |
st.subheader("Answer:")
|
| 51 |
|
|
|
|
| 3 |
# It takes as input: (1) The common core standard to use, (2) The area of interest
|
| 4 |
|
| 5 |
import streamlit as st
|
| 6 |
+
import json
|
| 7 |
|
| 8 |
from langchain.chat_models import ChatOpenAI
|
| 9 |
from langchain.schema import (
|
|
|
|
| 20 |
|
| 21 |
if "sessionMessages" not in st.session_state:
|
| 22 |
st.session_state.sessionMessages = [
|
| 23 |
+
SystemMessage(content = "You are a bot that generates free response questions based on the input of a Common Core Standard, and area of interest.\
|
| 24 |
+
The Human Input will be in JSON format. The Common Core Standard will be specified with the key cc-standard. The area of interest will \
|
| 25 |
+
be specified with the key area-of-interest.\
|
| 26 |
+
\
|
| 27 |
+
Give one response only for each JSON object. ")
|
| 28 |
]
|
| 29 |
|
| 30 |
|
|
|
|
| 38 |
|
| 39 |
#Gets the user input
|
| 40 |
def get_text():
|
| 41 |
+
input_text = st.text_area("Paste a JSON file here, with the following keys:(1) The name of the common core standard, (2) The student's area of interest. E.g. {\"cc-standard\": \"CCSS.ELA-LITERACY.W.4.9\", \"area-of-interest\": \"Baseball\" } ", key="input")
|
| 42 |
return input_text
|
| 43 |
|
| 44 |
chat = ChatOpenAI(temperature=0, model_name="gpt-4")
|
| 45 |
|
| 46 |
+
user_input = get_text()
|
| 47 |
+
|
| 48 |
|
| 49 |
|
| 50 |
submit = st.button('Generate')
|
| 51 |
|
| 52 |
#If generate button is clicked
|
| 53 |
if submit:
|
| 54 |
+
inputDict = json.loads(user_input)
|
| 55 |
+
print (inputDict)
|
| 56 |
response = load_answer(user_input)
|
| 57 |
st.subheader("Answer:")
|
| 58 |
|