Spaces:
Build error
Build error
Commit
·
d0de0d8
1
Parent(s):
04376ef
Update app.py
Browse files
app.py
CHANGED
|
@@ -166,4 +166,30 @@ if csv_file is not None:
|
|
| 166 |
st.write(class_schema)
|
| 167 |
|
| 168 |
# Ingest data into Weaviate
|
| 169 |
-
ingest_data_to_weaviate(dataframe, class_name, class_description)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
st.write(class_schema)
|
| 167 |
|
| 168 |
# Ingest data into Weaviate
|
| 169 |
+
ingest_data_to_weaviate(dataframe, class_name, class_description)
|
| 170 |
+
|
| 171 |
+
# Input for questions
|
| 172 |
+
questions = st.text_area("Enter your questions (one per line)")
|
| 173 |
+
questions = questions.split("\n") # split questions by line
|
| 174 |
+
questions = [q for q in questions if q] # remove empty strings
|
| 175 |
+
|
| 176 |
+
if st.button("Submit"):
|
| 177 |
+
if data and questions:
|
| 178 |
+
answers = summarize_map_reduce(data, questions)
|
| 179 |
+
st.write("Answers:")
|
| 180 |
+
for q, a in zip(questions, answers):
|
| 181 |
+
st.write(f"Question: {q}")
|
| 182 |
+
st.write(f"Answer: {a}")
|
| 183 |
+
|
| 184 |
+
# Add Ctrl+Enter functionality for submitting the questions
|
| 185 |
+
st.markdown("""
|
| 186 |
+
<script>
|
| 187 |
+
document.addEventListener("DOMContentLoaded", function(event) {
|
| 188 |
+
document.addEventListener("keydown", function(event) {
|
| 189 |
+
if (event.ctrlKey && event.key === "Enter") {
|
| 190 |
+
document.querySelector(".stButton button").click();
|
| 191 |
+
}
|
| 192 |
+
});
|
| 193 |
+
});
|
| 194 |
+
</script>
|
| 195 |
+
""", unsafe_allow_html=True)
|