Prageeth-1 commited on
Commit
22395c2
·
verified ·
1 Parent(s): 378b818

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -16
app.py CHANGED
@@ -81,11 +81,33 @@ st.markdown("""
81
  background-color: #ffffff;
82
  color : #FF6347;
83
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  </style>
85
  """, unsafe_allow_html=True)
86
 
 
 
 
 
 
 
 
87
  # App title and description
88
- st.title("Daily Mirror News Analyzer")
89
  st.markdown("""
90
  Analyze news excerpts with our powerful AI tools:
91
  - Classify news articles into categories
@@ -238,29 +260,36 @@ with tab2:
238
  st.header("Question Answering Pipeline")
239
  st.write("Ask questions about news content and get answers from our AI model.")
240
 
241
-
242
-
243
  if uploaded_file is not None:
244
-
245
  context = ' '.join(df['content'].tolist()) # Use predictions for Q&A
246
  st.write(f"Loaded {len(df)} news excerpts")
247
-
248
  else:
249
  st.warning("Please upload a CSV file.")
250
-
251
 
 
252
  question = st.text_input("Enter your question:")
253
 
254
- if st.button("Get Answer") and context and question:
255
- with st.spinner("Searching for answers..."):
256
- qa_pipeline = load_qa_model()
257
- result = qa_pipeline(question=question, context=context)
258
-
259
- st.subheader("Answer")
260
- st.success(result['answer'])
261
-
262
- st.subheader("Details")
263
- st.write(f"Confidence: {result['score']:.2f}")
 
 
 
 
 
 
 
 
 
 
264
 
265
 
266
  with tab3:
 
81
  background-color: #ffffff;
82
  color : #FF6347;
83
  }
84
+
85
+ .header {
86
+ display: flex;
87
+ align-items: center;
88
+ margin-bottom: 20px;
89
+ }
90
+ .header img {
91
+ height: 50px; /* Adjust logo size */
92
+ margin-right: 10px;
93
+ }
94
+ .header h3 {
95
+ font-size: 24px;
96
+ color: #4CAF50; /* Adjust the color of the header */
97
+ margin: 0;
98
+
99
  </style>
100
  """, unsafe_allow_html=True)
101
 
102
+ st.markdown("""
103
+ <div class="header">
104
+ <img src="https://via.placeholder.com/50x50?text=Logo" alt="Logo">
105
+ <h1>Daily Mirror News Analyzer</h1>
106
+ </div>
107
+ """, unsafe_allow_html=True)
108
+
109
  # App title and description
110
+
111
  st.markdown("""
112
  Analyze news excerpts with our powerful AI tools:
113
  - Classify news articles into categories
 
260
  st.header("Question Answering Pipeline")
261
  st.write("Ask questions about news content and get answers from our AI model.")
262
 
 
 
263
  if uploaded_file is not None:
264
+ # Load the CSV and prepare context for the model
265
  context = ' '.join(df['content'].tolist()) # Use predictions for Q&A
266
  st.write(f"Loaded {len(df)} news excerpts")
 
267
  else:
268
  st.warning("Please upload a CSV file.")
 
269
 
270
+ # Input field for the question
271
  question = st.text_input("Enter your question:")
272
 
273
+ # Handle the "Get Answer" button
274
+ if st.button("Get Answer"):
275
+ if uploaded_file is None:
276
+ # Display an error message if no file is uploaded
277
+ st.error("Please upload a CSV file before asking a question.")
278
+ elif context and question:
279
+ # If both a file and a question are provided, answer the question
280
+ with st.spinner("Searching for answers..."):
281
+ qa_pipeline = load_qa_model() # Ensure this function is defined elsewhere
282
+ result = qa_pipeline(question=question, context=context)
283
+
284
+ # Display the answer and details
285
+ st.subheader("Answer")
286
+ st.success(result['answer'])
287
+
288
+ st.subheader("Details")
289
+ st.write(f"Confidence: {result['score']:.2f}")
290
+ else:
291
+ st.error("Please enter a question.")
292
+
293
 
294
 
295
  with tab3: