Shruti9756 commited on
Commit
fd7b7b0
Β·
verified Β·
1 Parent(s): 3a49835

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -59
app.py DELETED
@@ -1,59 +0,0 @@
1
- import streamlit as st
2
- from transformers import pipeline, AutoTokenizer
3
- import base64
4
-
5
- # Load the GPT-2 text generation model from Hugging Face
6
- text_generator = pipeline("text-generation", model="Shruti9756/G24_Contract_Summarization_step3")
7
-
8
- # Increase the maximum token limit
9
- tokenizer = AutoTokenizer.from_pretrained("Shruti9756/G24_Contract_Summarization_step3")
10
- text_generator.model.config.max_position_embeddings = tokenizer.model_max_length
11
-
12
- # Function to generate text using the GPT-2 model
13
- def generate_text(prompt):
14
- generated_text = text_generator(prompt, max_length=300, num_return_sequences=1, temperature=0.7)[0]['generated_text']
15
- return generated_text
16
-
17
- # # Function to handle feedback and store it in a CSV file
18
- # def handle_feedback(feedback_data, feedback_file):
19
- # # Your existing feedback handling logic remains the same
20
-
21
- # # Function to create a download link for a binary file
22
- # def get_binary_file_downloader_html(file_path, file_label):
23
- # # Your existing file downloader logic remains the same
24
-
25
- # Main Streamlit app
26
- def main():
27
- st.title("Text Generation with Feedback")
28
-
29
- # Input area for prompt
30
- prompt = st.text_area("Enter a prompt:", height=100)
31
-
32
- # Button to generate text
33
- if st.button("Generate Text"):
34
- generated_text = generate_text(prompt)
35
- st.subheader("Generated Text:")
36
- st.write(generated_text)
37
-
38
- # Feedback section
39
- st.subheader("Feedback:")
40
- thumbs_up = st.button("πŸ‘")
41
- thumbs_down = st.button("πŸ‘Ž")
42
-
43
- chosen = "πŸ‘" if thumbs_up else None
44
- rejected = "πŸ‘Ž" if thumbs_down else None
45
-
46
- # feedback_data.append((prompt, generated_text, chosen, rejected))
47
-
48
- # Handle feedback data
49
- # if feedback_data:
50
- # feedback_file = 'feedback.csv'
51
- # st.session_state.feedback_csv_exists = True
52
- # handle_feedback(feedback_data, feedback_file)
53
-
54
- # Initialize feedback data
55
- # feedback_data = []
56
-
57
- # Run the app
58
- if __name__ == "__main__":
59
- main()