Shruti9756 commited on
Commit
1c1b6e5
Β·
verified Β·
1 Parent(s): 43efb38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -31
app.py CHANGED
@@ -1,32 +1,33 @@
1
  import streamlit as st
2
- from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
-
4
- # Load pre-trained model and tokenizer
5
- model_name = "Laksitha/autotrain-tosdr_tldr_legal_summarisation_v1-1434353657"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
-
9
- # Streamlit app
10
- st.title("Legal Summary Generator")
11
-
12
- # User input
13
- user_input = st.text_area("Enter legal text:")
14
-
15
- # Generate summary
16
- if st.button("Generate Summary"):
17
- if user_input:
18
- # Tokenize input and generate summary
19
- input_ids = tokenizer.encode(user_input, return_tensors="pt", max_length=1024, truncation=True)
20
- output = model.generate(input_ids, max_length=150, num_beams=2, length_penalty=0.8, early_stopping=True)
21
-
22
- # Decode and display generated summary
23
- generated_summary = tokenizer.decode(output[0], skip_special_tokens=True)
24
- st.write("Generated Summary:")
25
- st.write(generated_summary)
26
- else:
27
- st.warning("Please enter legal text for summarization.")
28
-
29
- # Additional features or explanations
30
- st.write("\n\n")
31
- st.subheader("About This Demo")
32
- st.write("This is a simple Streamlit app for generating legal summaries.")
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ import os
4
+
5
+ # Function to store feedback in a file
6
+ def store_feedback(contract_text, feedback, filename='feedback_data.csv'):
7
+ feedback_data = pd.read_csv(filename) if os.path.exists(filename) else pd.DataFrame(columns=['Contract', 'Feedback'])
8
+
9
+ feedback_data = feedback_data.append({'Contract': contract_text, 'Feedback': feedback}, ignore_index=True)
10
+ feedback_data.to_csv(filename, index=False)
11
+
12
+ # Main Streamlit app
13
+ def main():
14
+ st.title("Contract Summarizer with Feedback")
15
+
16
+ # Get contract input from user
17
+ contract_text = st.text_area("Paste your contract here:")
18
+
19
+ # Display the input contract
20
+ st.subheader("Input Contract:")
21
+ st.write(contract_text)
22
+
23
+ # Get feedback from the user using emojis
24
+ feedback = st.radio("Feedback:", ['πŸ‘', 'πŸ‘Ž'])
25
+
26
+ if st.button("Submit Feedback"):
27
+ # Store the feedback in a file
28
+ store_feedback(contract_text, feedback)
29
+ st.success("Feedback submitted successfully!")
30
+
31
+ # Run the app
32
+ if __name__ == "__main__":
33
+ main()