Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,25 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 3 |
|
| 4 |
-
st.title("
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
prompt =
|
| 8 |
-
f"Create a detailed guide on {topic}. Include instructions, tips, and benefits."
|
| 9 |
-
)
|
| 10 |
llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["API_KEY"])
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
return
|
| 14 |
|
| 15 |
-
with st.form("
|
| 16 |
-
|
| 17 |
-
submitted = st.form_submit_button("
|
| 18 |
|
| 19 |
-
if submitted and
|
| 20 |
-
|
| 21 |
-
st.subheader("
|
| 22 |
-
st.write(
|
| 23 |
-
elif submitted and not
|
| 24 |
-
st.error("Please enter
|
| 25 |
|
| 26 |
-
if st.button("Need
|
| 27 |
-
st.write("
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 3 |
|
| 4 |
+
st.title("Text Summarizer")
|
| 5 |
|
| 6 |
+
def generate_summary(text):
|
| 7 |
+
prompt = f"Summarize the following text: {text}"
|
|
|
|
|
|
|
| 8 |
llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["API_KEY"])
|
| 9 |
+
summary = llm.invoke(prompt)
|
| 10 |
+
summary = summary.content
|
| 11 |
+
return summary
|
| 12 |
|
| 13 |
+
with st.form("text_summarizer_form"):
|
| 14 |
+
text = st.text_area("Enter the text you want to summarize")
|
| 15 |
+
submitted = st.form_submit_button("Summarize")
|
| 16 |
|
| 17 |
+
if submitted and text:
|
| 18 |
+
summary = generate_summary(text)
|
| 19 |
+
st.subheader("Summary:")
|
| 20 |
+
st.write(summary)
|
| 21 |
+
elif submitted and not text:
|
| 22 |
+
st.error("Please enter text to summarize.")
|
| 23 |
|
| 24 |
+
if st.button("Need Inspiration?"):
|
| 25 |
+
st.write("Summarizing can help you understand the key points quickly. Keep practicing!")
|