-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamlit_app.py
105 lines (91 loc) · 3.59 KB
/
streamlit_app.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import streamlit as st
from agents import clarification_agent, solution_agent, quality_assurance_agent, concise_answer_agent
def main():
st.set_page_config(page_title="Homework Helper", page_icon=":books:", layout="wide")
# Custom CSS to style the app
st.markdown("""
<style>
.main {
background-color: #f0f2f6;
padding: 20px;
border-radius: 10px;
}
.stButton>button {
background-color: #4CAF50;
color: white;
border-radius: 12px;
padding: 10px 20px;
margin: 10px 0;
font-size: 16px;
}
.stTextArea textarea {
border-radius: 10px;
border: 1px solid #d1d9e6;
}
.stAlert {
background-color: #fff;
border-radius: 10px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.stAlert>div {
font-size: 16px;
}
.stExpander {
background-color: #fff;
border-radius: 10px;
padding: 20px;
margin-top: 20px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.stExpander>div>div {
font-size: 16px;
}
</style>
""", unsafe_allow_html=True)
# Title and description
st.title("Homework Helper :books:")
st.write("""
Welcome to the Homework Helper! Ask any homework question and get help from multiple AI agents.
Enter your question in the text box below and press "Get Help" to see the answers.
""")
# Input section
st.header("Enter Your Homework Question")
question = st.text_area("Type your question here:", height=150)
if st.button("Get Help"):
if question.strip():
# Clarification agent
with st.spinner("Checking clarity of the question..."):
clarification = clarification_agent(question)
if "need more details" in clarification.lower():
st.error("Clarification needed. Please provide more details for the question.")
st.info(clarification)
else:
# Solution agent
with st.spinner("Generating solution..."):
solution = solution_agent(question)
# Quality assurance agent
with st.spinner("Reviewing solution for quality..."):
review = quality_assurance_agent(solution)
# Concise answer agent
with st.spinner("Generating concise answer..."):
concise_answer = concise_answer_agent(solution)
# Display results
st.header("Results")
st.subheader("Concise Answer")
st.success(concise_answer)
st.subheader("Detailed Solution")
st.info(solution)
# Add expanders for detailed agent responses
st.header("Agent Reasoning")
with st.expander("Clarification Agent Response"):
st.write(clarification)
with st.expander("Solution Agent Response"):
st.write(solution)
with st.expander("Quality Assurance Agent Response"):
st.write(review)
else:
st.warning("Please enter a question.")
if __name__ == "__main__":
main()