Spaces:
Sleeping
Sleeping
save
Browse files
app.py
CHANGED
|
@@ -87,14 +87,31 @@ with st.spinner("AI is thinking..."):
|
|
| 87 |
st.session_state.uploaded_pdf_path = get_local_pdf_path()
|
| 88 |
|
| 89 |
filepath = st.session_state.uploaded_pdf_path
|
| 90 |
-
text_prompt =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
response = multimodal_prompt(filepath, text_prompt) # Use the local filepath
|
| 92 |
st.markdown(response)
|
| 93 |
|
| 94 |
try:
|
| 95 |
problems = json.loads(response)
|
|
|
|
| 96 |
for problem in problems:
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
except json.JSONDecodeError:
|
| 99 |
st.write("Error: Invalid JSON format in the response.")
|
| 100 |
except Exception as e:
|
|
|
|
| 87 |
st.session_state.uploaded_pdf_path = get_local_pdf_path()
|
| 88 |
|
| 89 |
filepath = st.session_state.uploaded_pdf_path
|
| 90 |
+
text_prompt = """Use the provided document. "Read the list of 5 quadratic equations.
|
| 91 |
+
Return your response in JSON format, as a list of strings.
|
| 92 |
+
Do not include any extra text, explanations, or backslashes.
|
| 93 |
+
|
| 94 |
+
Example JSON output:
|
| 95 |
+
[
|
| 96 |
+
"x^2 - 5x + 6 = 0",
|
| 97 |
+
"2x^2 + 3x - 1 = 0",
|
| 98 |
+
"x^2 - 9 = 0",
|
| 99 |
+
"3x^2 - 2x + 4 = 0",
|
| 100 |
+
"x^2 + 8x + 15 = 0"
|
| 101 |
+
]
|
| 102 |
+
"""
|
| 103 |
response = multimodal_prompt(filepath, text_prompt) # Use the local filepath
|
| 104 |
st.markdown(response)
|
| 105 |
|
| 106 |
try:
|
| 107 |
problems = json.loads(response)
|
| 108 |
+
equations = []
|
| 109 |
for problem in problems:
|
| 110 |
+
equation = problem.split(": ")[1] #Split the string at ": " and take the second part.
|
| 111 |
+
equations.append(equation)
|
| 112 |
+
st.write("Equations only:")
|
| 113 |
+
for equation in equations:
|
| 114 |
+
st.write(equation)
|
| 115 |
except json.JSONDecodeError:
|
| 116 |
st.write("Error: Invalid JSON format in the response.")
|
| 117 |
except Exception as e:
|