Update app.py
Browse files
app.py
CHANGED
|
@@ -15,14 +15,37 @@ import ast
|
|
| 15 |
generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|
| 16 |
|
| 17 |
# Streamlit chat UI
|
| 18 |
-
st.title("GPT-3 Chatbox")
|
| 19 |
|
| 20 |
-
user_input = st.text_input("You: ", "Hello, how are you?")
|
| 21 |
|
| 22 |
-
if user_input:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
################ STATEMENT SUMMARIZATION #################
|
| 28 |
|
|
|
|
| 15 |
generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|
| 16 |
|
| 17 |
# Streamlit chat UI
|
| 18 |
+
#st.title("GPT-3 Chatbox")
|
| 19 |
|
| 20 |
+
# user_input = st.text_input("You: ", "Hello, how are you?")
|
| 21 |
|
| 22 |
+
# if user_input:
|
| 23 |
+
# response = generator(user_input, max_length=100, num_return_sequences=1)[0]['generated_text']
|
| 24 |
+
# st.write(f"GPT-3: {response}")
|
| 25 |
|
| 26 |
+
# Define the summarization function
|
| 27 |
+
def chat(txt):
|
| 28 |
+
st.write('\n\n')
|
| 29 |
+
#st.write(txt[:100]) # Display the first 100 characters of the article
|
| 30 |
+
#st.write('--------------------------------------------------------------')
|
| 31 |
+
#summary = summarizer(txt, max_length=500, min_length=30, do_sample=False)
|
| 32 |
+
#st.write(summary[0]['summary_text'])
|
| 33 |
+
response = generator(txt, max_length=100, num_return_sequences=1)[0]['generated_text']
|
| 34 |
+
st.write(f"GPT-3: {response}")
|
| 35 |
+
|
| 36 |
+
DEFAULT_CHAT = ""
|
| 37 |
+
# Create a text area for user input
|
| 38 |
+
CHAT = st.sidebar.text_area('Enter Chat (String)', DEFAULT_CHAT, height=150)
|
| 39 |
+
|
| 40 |
+
# Enable the button only if there is text in the CHAT variable
|
| 41 |
+
if CHAT:
|
| 42 |
+
if st.sidebar.button('Chat Statement'):
|
| 43 |
+
# Call your Summarize function here
|
| 44 |
+
chat(CHAT) # Directly pass the your
|
| 45 |
+
else:
|
| 46 |
+
st.sidebar.button('Summarize Statement', disabled=True)
|
| 47 |
+
st.warning('👈 Please enter Statement!')
|
| 48 |
+
|
| 49 |
|
| 50 |
################ STATEMENT SUMMARIZATION #################
|
| 51 |
|