Spaces:
Running
Running
File size: 918 Bytes
c72f44e 52a3e2b c72f44e 493a6ce c72f44e 493a6ce b286257 493a6ce b286257 493a6ce 6677c09 493a6ce 6677c09 b286257 493a6ce b286257 6677c09 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import streamlit as st
#from langchain.llms import OpenAI
from langchain_community.llms import OpenAI
st.title("ask me anything!")
def mathematics(topic):
# Enhanced prompt with additional context for better post generation
prompt =(
f"Calculate cost based on unit rate."
"Example: 20 chocolates for Rs 320. Find cost for 35 chocolates."
"Format: Given: 20 chocolates = Rs 320. Cost per chocolate = (320/20)."
"Cost for 35 = (320/20) × 35 = Rs 560.solve this {topic}"
)
llm = OpenAI(temperature=0.7, openai_api_key=st.secrets["OPENAI_API_KEY"])
response = llm(prompt)
return response
with st.form("my_form"):
topic = st.text_area("mathematics with Adolina")
submitted = st.form_submit_button("Ask Spot")
if submitted and topic:
post = mathematics(topic)
st.info(post)
elif submitted and not topic:
st.error("Give me problems.") |