Abhaykoul commited on
Commit
1db2e27
1 Parent(s): 503e5c4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as palm
3
+
4
+ # Information about obtaining a free API key
5
+ st.sidebar.info("Get your free palm2 API key at [makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey)")
6
+
7
+ # Ask the user for palm2 API key if not provided
8
+ api_key = st.sidebar.text_input("Enter your palm2 API key:", type="password")
9
+ if not api_key:
10
+ st.warning("Please enter your palm2 API key.")
11
+ st.stop()
12
+
13
+ # Configure the API key
14
+ palm.configure(api_key=api_key)
15
+
16
+ # Styling for the title
17
+ st.title("Auto Study Notes Generator")
18
+ st.markdown("---")
19
+
20
+ # Sidebar for settings
21
+ st.sidebar.title("Settings")
22
+ user_class = st.sidebar.selectbox('Select your class:', ['Class 1', 'Class 2', 'Class 3', 'Class 4', 'Class 5', 'Class 6',
23
+ 'Class 7', 'Class 8', 'Class 9', 'Class 10', 'Class 11', 'Class 12'])
24
+ st.sidebar.markdown("---")
25
+
26
+ # Main content area
27
+ st.header(f"Study Notes Generation for {user_class}")
28
+ user_input = st.text_input('Enter your study topic:')
29
+ st.markdown("---")
30
+
31
+ # Generate button
32
+ if st.button('Generate Study Notes'):
33
+ if user_input.lower() in ['quit', 'exit', 'bye']:
34
+ st.success("Goodbye! Have a great day!")
35
+ else:
36
+ with st.spinner("Generating study notes. Please wait..."):
37
+ st.subheader(f"Making notes for you on '{user_input}'")
38
+ prompt = f"Provide study notes for {user_class} on the topic: {user_input}."
39
+ response = palm.generate_text(model='models/text-bison-001', prompt=prompt)
40
+ study_notes = response.result
41
+
42
+ # Display the generated study notes
43
+ st.subheader(f"Study Notes for {user_class} - {user_input}:")
44
+ st.write(study_notes)
45
+
46
+ # Add a footer with updated text
47
+ st.sidebar.markdown("---")
48
+ st.sidebar.text("© 2023 HelpingAI")
49
+
50
+ # Hide Streamlit menu
51
+ st.markdown("""
52
+ <style>
53
+ #MainMenu {visibility: hidden;}
54
+ </style>
55
+ """, unsafe_allow_html=True)