Sachitksh commited on
Commit
1616856
·
verified ·
1 Parent(s): 2907624

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -12
app.py CHANGED
@@ -1,17 +1,30 @@
1
  import streamlit as st
2
- from langchain_google_genai import ChatGoogleGenerativeAI
 
3
 
4
- st.title("Gemini ChatBOT")
5
 
6
- def llm_response(user_input):
7
- llm = ChatGoogleGenerativeAI(model="gemini-pro")
8
- result = llm.invoke(user_input)
9
- return result.content
10
 
11
- user_input = st.text_area("Enter your query here...")
 
 
 
12
 
13
- if st.button("Get Response") and user_input:
14
- with st.spinner("Generating Response..."):
15
- answer = llm_response(user_input)
16
- st.success('Great! Response generated successfully')
17
- st.write(answer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ #from langchain.llms import OpenAI
3
+ from langchain_community.llms import OpenAI
4
 
 
5
 
6
+ st.title("Maths Problem Solving with Adolina!")
 
 
 
7
 
8
+ def mathematics(topic):
9
+ # Enhanced prompt with additional context for better post generation
10
+ prompt =(
11
+ f"solve this :{topic} as a CBSE Board Mathematics Teacher, you need to provide solutions for the questions asked in the following format:"
12
 
13
+ "1. Problem Statement: State the problem clearly."
14
+ "2. Solution Approach: Solve as per CBSE guidelines."
15
+ "3. Step-by-Step Solution: Show the method of solution."
16
+ "4. Final Answer: Clearly present the final answer, with any necessary units or explanations."
17
+ )
18
+ llm = OpenAI(temperature=0.7, openai_api_key=st.secrets["sk-proj-q7ZheuD9p1QQ9zdOFcesT3BlbkFJ8zIk4TSUwCDpYrOIk0nV"])
19
+ response = llm(prompt)
20
+ return response
21
+
22
+ with st.form("my_form"):
23
+ topic = st.text_area("Mathematics with Adolina")
24
+
25
+ submitted = st.form_submit_button("Ask to Spot")
26
+ if submitted and topic:
27
+ post = mathematics(topic)
28
+ st.info(post)
29
+ elif submitted and not topic:
30
+ st.error("Give me problems.")