iqra785 commited on
Commit
0020a82
·
verified ·
1 Parent(s): e907539

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -29
app.py CHANGED
@@ -5,7 +5,7 @@ from ai_utils import generate_response as _generate_response
5
  # Set the page configuration to wide layout
6
  st.set_page_config(layout="wide")
7
 
8
- # Custom CSS to style the page and text area
9
  st.markdown("""
10
  <style>
11
  .main .block-container {
@@ -30,11 +30,6 @@ st.markdown("""
30
  margin: 0.5rem 0;
31
  background-color: #f9f9f9;
32
  }
33
- .stTextArea textarea {
34
- font-size: 16px;
35
- border-radius: 5px;
36
- border: 2px solid #ddd;
37
- }
38
  </style>
39
  """, unsafe_allow_html=True)
40
 
@@ -53,13 +48,7 @@ st.write("""
53
 
54
  # Input area for text
55
  st.subheader("Enter Your Text")
56
- st.session_state.input_text = st.text_area(
57
- label="Enter text below:",
58
- value=st.session_state.input_text,
59
- height=200,
60
- key="input_text",
61
- help="Paste or type your text here for processing."
62
- )
63
 
64
  # Text Processing
65
  if st.session_state.input_text:
@@ -79,12 +68,9 @@ if st.session_state.input_text:
79
  st.text_area("Summary", value=st.session_state.summary, height=200, key="summary", help="Summary of the input text.")
80
 
81
  if st.button("Extract Main Points"):
82
- main_points_prompt = "Extract the main points from the following text and format them as a bulleted list:"
83
  st.session_state.main_points = generate_response(main_points_prompt, st.session_state.input_text)
84
- # Format main points as a bulleted list
85
- if st.session_state.main_points:
86
- bullet_points = "\n".join([f"- {point.strip()}" for point in st.session_state.main_points.split("\n")])
87
- st.markdown(f"### Main Points\n{bullet_points}", unsafe_allow_html=True)
88
 
89
  if st.button("Generate Flashcards"):
90
  flashcards_prompt = "Create flashcards with questions and answers based on the following text:"
@@ -107,19 +93,14 @@ if st.session_state.summary or st.session_state.main_points or st.session_state.
107
  st.text_area("Summary", value=st.session_state.summary, height=200, key="summary_results", help="Generated summary.")
108
 
109
  st.subheader("Main Points")
110
- if st.session_state.main_points:
111
- bullet_points = "\n".join([f"- {point.strip()}" for point in st.session_state.main_points.split("\n")])
112
- st.markdown(f"### Main Points\n{bullet_points}", unsafe_allow_html=True) # Displaying the main points as a bulleted list
113
 
114
  st.subheader("Flashcards")
115
- if st.session_state.flashcards:
116
- flashcards = st.session_state.flashcards.split("\n\n") # Assuming flashcards are separated by double newlines
117
- for card in flashcards:
118
- st.markdown(f"""
119
- <div class="flashcard">
120
- {card}
121
- </div>
122
- """, unsafe_allow_html=True)
123
 
124
  st.subheader("Download Results")
125
  results = f"Summary:\n{st.session_state.summary}\n\nMain Points:\n{st.session_state.main_points}\n\nFlashcards:\n{st.session_state.flashcards}"
 
5
  # Set the page configuration to wide layout
6
  st.set_page_config(layout="wide")
7
 
8
+ # Custom CSS to style the page
9
  st.markdown("""
10
  <style>
11
  .main .block-container {
 
30
  margin: 0.5rem 0;
31
  background-color: #f9f9f9;
32
  }
 
 
 
 
 
33
  </style>
34
  """, unsafe_allow_html=True)
35
 
 
48
 
49
  # Input area for text
50
  st.subheader("Enter Your Text")
51
+ st.session_state.input_text = st.text_area("Enter text below:", height=200, key="input_text")
 
 
 
 
 
 
52
 
53
  # Text Processing
54
  if st.session_state.input_text:
 
68
  st.text_area("Summary", value=st.session_state.summary, height=200, key="summary", help="Summary of the input text.")
69
 
70
  if st.button("Extract Main Points"):
71
+ main_points_prompt = "Extract the main points from the following text:"
72
  st.session_state.main_points = generate_response(main_points_prompt, st.session_state.input_text)
73
+ st.text_area("Main Points", value=st.session_state.main_points, height=200, key="main_points", help="Main points extracted from the input text.")
 
 
 
74
 
75
  if st.button("Generate Flashcards"):
76
  flashcards_prompt = "Create flashcards with questions and answers based on the following text:"
 
93
  st.text_area("Summary", value=st.session_state.summary, height=200, key="summary_results", help="Generated summary.")
94
 
95
  st.subheader("Main Points")
96
+ st.text_area("Main Points", value=st.session_state.main_points, height=200, key="main_points_results", help="Extracted main points.")
 
 
97
 
98
  st.subheader("Flashcards")
99
+ st.markdown("""
100
+ <div class="flashcard">
101
+ {flashcards}
102
+ </div>
103
+ """, unsafe_allow_html=True)
 
 
 
104
 
105
  st.subheader("Download Results")
106
  results = f"Summary:\n{st.session_state.summary}\n\nMain Points:\n{st.session_state.main_points}\n\nFlashcards:\n{st.session_state.flashcards}"