Ismetdh commited on
Commit
f7caf36
·
verified ·
1 Parent(s): f9adfbf

Upload 2 files

Browse files
Files changed (2) hide show
  1. LLM_inteface.py +41 -0
  2. requirements.txt +1 -0
LLM_inteface.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import re
3
+ import nltk
4
+ nltk.download('punkt') # Ensure sentence tokenizers are available.
5
+ # Import your summarizer. Replace these paths with your actual model and tokenizer paths.
6
+ from summarizer import Summarizer
7
+
8
+ def clean_text(text):
9
+ """
10
+ Cleans the text by removing extra whitespace.
11
+ You can expand this function to include additional cleaning as needed.
12
+ """
13
+ cleaned = re.sub(r'\s+', ' ', text).strip()
14
+ return cleaned
15
+
16
+ # Initialize your summarizer. Make sure to set the correct paths.
17
+ MODEL_PATH = r"server_side_summarize_news" # Replace with your model path.
18
+ TOKENIZER_PATH = r"server_side_summarize_news" # Replace with your tokenizer path.
19
+ summarizer = Summarizer(MODEL_PATH, TOKENIZER_PATH)
20
+
21
+ # Set up the Streamlit UI.
22
+ st.title("Text Summarizer")
23
+ st.write("Enter your text below to generate a summary:")
24
+
25
+ # Text area for user input.
26
+ input_text = st.text_area("Input Text", height=200)
27
+
28
+ # When the 'Summarize' button is pressed, process the input.
29
+ if st.button("Summarize"):
30
+ if not input_text.strip():
31
+ st.warning("Please enter some text to summarize.")
32
+ else:
33
+ # Clean the input text.
34
+ cleaned_text = clean_text(input_text)
35
+ try:
36
+ # Generate the summary using your summarizer.
37
+ summary = summarizer.iterative_summarization(cleaned_text)
38
+ st.subheader("Summary")
39
+ st.write(summary)
40
+ except Exception as e:
41
+ st.error(f"An error occurred during summarization: {e}")
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit_pills