Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,16 @@
|
|
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
|
8 |
-
|
9 |
-
|
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")
|
@@ -19,29 +18,55 @@ st.markdown("---")
|
|
19 |
|
20 |
# Sidebar for settings
|
21 |
st.sidebar.title("Settings")
|
22 |
-
|
23 |
-
|
24 |
-
st.sidebar.
|
25 |
|
26 |
# Main content area
|
27 |
-
|
28 |
-
|
29 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
#
|
32 |
-
if
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
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("---")
|
@@ -52,4 +77,4 @@ st.markdown("""
|
|
52 |
<style>
|
53 |
#MainMenu {visibility: hidden;}
|
54 |
</style>
|
55 |
-
""", unsafe_allow_html=True)
|
|
|
1 |
import streamlit as st
|
2 |
import google.generativeai as palm
|
3 |
+
from gradio_client import Client
|
4 |
+
|
5 |
+
# Initialize the Gradio client with the API URL
|
6 |
+
client = Client("https://akdeniz27-llama-2-70b-chat-hf-with-easyllm.hf.space/")
|
7 |
|
8 |
# Information about obtaining a free API key
|
9 |
st.sidebar.info("Get your free palm2 API key at [makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey)")
|
10 |
|
11 |
+
# Ask the user for palm2 API key
|
12 |
+
api_key_palm2 = st.sidebar.text_input("Enter your palm2 API key for study notes:", type="password")
|
13 |
+
palm.configure(api_key=api_key_palm2)
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Styling for the title
|
16 |
st.title("Auto Study Notes Generator")
|
|
|
18 |
|
19 |
# Sidebar for settings
|
20 |
st.sidebar.title("Settings")
|
21 |
+
|
22 |
+
# User choice for mode selection
|
23 |
+
selected_mode = st.sidebar.radio("Select Mode:", ['Generate Study Notes (Palm2)', 'Use Llama 70b for Notes'])
|
24 |
|
25 |
# Main content area
|
26 |
+
if selected_mode == 'Generate Study Notes (Palm2)':
|
27 |
+
st.header("Study Notes Generation (Palm2)")
|
28 |
+
user_class = st.sidebar.selectbox('Select your class:', ['Class 1', 'Class 2', 'Class 3', 'Class 4', 'Class 5', 'Class 6',
|
29 |
+
'Class 7', 'Class 8', 'Class 9', 'Class 10', 'Class 11', 'Class 12'])
|
30 |
+
user_input = st.text_input(f'Enter your study topic for {user_class}:')
|
31 |
+
st.markdown("---")
|
32 |
+
|
33 |
+
if st.button('Generate Study Notes'):
|
34 |
+
if user_input.lower() in ['quit', 'exit', 'bye']:
|
35 |
+
st.success("Goodbye! Have a great day!")
|
36 |
+
else:
|
37 |
+
with st.spinner("Generating study notes. Please wait..."):
|
38 |
+
st.subheader(f"Making notes for you on '{user_input}'")
|
39 |
+
prompt = f"Provide study notes for {user_class} on the topic: {user_input}."
|
40 |
+
response = palm.generate_text(model='models/text-bison-001', prompt=prompt)
|
41 |
+
study_notes = response.result
|
42 |
+
|
43 |
+
# Display the generated study notes
|
44 |
+
st.subheader(f"Study Notes for {user_class} - {user_input}:")
|
45 |
+
st.write(study_notes)
|
46 |
+
|
47 |
+
elif selected_mode == 'Use Llama 70b for Notes':
|
48 |
+
st.header("Llama 70b Mode")
|
49 |
+
llama_input = st.text_input('Enter a message for Llama 70b (type "exit" to quit):')
|
50 |
+
st.markdown("---")
|
51 |
+
|
52 |
+
if st.button('Get Llama 70b Response'):
|
53 |
+
if llama_input.lower() == 'exit':
|
54 |
+
st.success("Exiting Llama 70b mode. Have a great day!")
|
55 |
+
else:
|
56 |
+
with st.spinner("Getting response from Llama 70b. Please wait..."):
|
57 |
+
# Make a prediction using Llama 70b API
|
58 |
+
llama_result = client.predict(
|
59 |
+
llama_input,
|
60 |
+
api_name="/chat"
|
61 |
+
)
|
62 |
|
63 |
+
# Check if the result is not None
|
64 |
+
if llama_result is not None:
|
65 |
+
# Display the result
|
66 |
+
st.subheader("Llama 70b Response:")
|
67 |
+
st.write(llama_result)
|
68 |
+
else:
|
69 |
+
st.warning("Llama 70b API response was None. Please try again later.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
# Add a footer with updated text
|
72 |
st.sidebar.markdown("---")
|
|
|
77 |
<style>
|
78 |
#MainMenu {visibility: hidden;}
|
79 |
</style>
|
80 |
+
""", unsafe_allow_html=True)
|