-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
33 lines (28 loc) · 1 KB
/
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
import streamlit as st
import openai
import os
from text_summarizer.functions import summarize, search
try:
# Please update your key in the .secret/secretkey.toml
openai.api_key = os.getenv('OPENAI_KEY')
if "summary" not in st.session_state:
st.session_state["summary"] = ""
if "summary_ddg" not in st.session_state:
st.session_state["summary_ddg"] = ""
st.title("Text Summarizer")
input_text = st.text_area(label="Enter full text:", value="", height=250)
st.button(
"Submit",
on_click=summarize,
kwargs={"prompt": input_text},
)
st.button(
"Search",
on_click=search,
kwargs={"prompt": input_text},
)
sesh_state = st.session_state["summary"] if st.session_state["summary"] else st.session_state["search"]
output_text = st.text_area(label="Result", value=sesh_state, height=250)
#output_text_search = st.text_area(label="Summarized by Duck Duck Go:", value=st.session_state["search"], height=250)
except:
st.write('There was an error =(')