Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain_community.llms import OpenAI
|
| 3 |
+
|
| 4 |
+
st.title("Maths Problem Solving with Adolina!")
|
| 5 |
+
|
| 6 |
+
def mathematics(topic):
|
| 7 |
+
prompt = (
|
| 8 |
+
f"Solve this: {topic} as a CBSE Board Mathematics Teacher. "
|
| 9 |
+
"You need to provide solutions for the questions asked in the following format:\n\n"
|
| 10 |
+
"1. Problem Statement: State the problem clearly.\n"
|
| 11 |
+
"2. Solution Approach: Solve as per CBSE guidelines.\n"
|
| 12 |
+
"3. Step-by-Step Solution: Show the method of solution.\n"
|
| 13 |
+
"4. Final Answer: Clearly present the final answer, with any necessary units or explanations."
|
| 14 |
+
)
|
| 15 |
+
llm = OpenAI(temperature=0.7, openai_api_key=st.secrets["sk-proj-q7ZheuD9p1QQ9zdOFcesT3BlbkFJ8zIk4TSUwCDpYrOIk0nV"])
|
| 16 |
+
response = llm(prompt)
|
| 17 |
+
return response
|
| 18 |
+
|
| 19 |
+
with st.form("my_form"):
|
| 20 |
+
topic = st.text_area("Mathematics with Adolina")
|
| 21 |
+
|
| 22 |
+
submitted = st.form_submit_button("Ask to Spot")
|
| 23 |
+
if submitted and topic:
|
| 24 |
+
post = mathematics(topic)
|
| 25 |
+
st.info(post)
|
| 26 |
+
elif submitted and not topic:
|
| 27 |
+
st.error("Give me problems.")
|