jackkuo commited on
Commit
b05950c
·
verified ·
1 Parent(s): 89d1918

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -52
app.py CHANGED
@@ -506,56 +506,57 @@ if query or search_button:
506
  st.markdown(
507
  f"**[Full Text Read]({doi_link})** 🔗", unsafe_allow_html=True
508
  )
509
-
510
- plot_df = pd.DataFrame(plot_data)
511
-
512
- # Convert 'Date' to datetime if it's not already in that format
513
- plot_df["Date"] = pd.to_datetime(plot_df["Date"])
514
-
515
- # Sort the DataFrame based on the Date to make sure it's ordered
516
- plot_df = plot_df.sort_values(by="Date")
517
-
518
-
519
- # Create a Plotly figure
520
- fig = px.scatter(
521
- plot_df,
522
- x="Date",
523
- y="Score",
524
- hover_data=["Title", "DOI"],
525
- color='server',
526
- title="Publication Times and Scores",
527
- )
528
- fig.update_traces(marker=dict(size=10))
529
- # Customize hover text to display the title and link it to the DOI
530
- fig.update_traces(
531
- hovertemplate="<b>%{hovertext}</b>",
532
- hovertext=plot_df.apply(lambda row: f"{row['Title']}", axis=1),
533
- )
534
-
535
- # Show the figure in the Streamlit app
536
- st.plotly_chart(fig, use_container_width=True)
537
-
538
- # Generate category counts for the pie chart
539
- category_counts = plot_df["category"].value_counts().reset_index()
540
- category_counts.columns = ["category", "count"]
541
-
542
- # Create a pie chart with Plotly Express
543
- fig = px.pie(
544
- category_counts,
545
- values="count",
546
- names="category",
547
- title="Category Distribution",
548
- )
549
-
550
- # Show the pie chart in the Streamlit app
551
- st.plotly_chart(fig, use_container_width=True)
552
-
553
- prompt = st.text_area("Enter your summary prompt", value=LLM_prompt)
554
- summary_button = st.button("AI summary")
555
- if summary_button:
556
- ai_gen_start = time.time()
557
- st.markdown('**AI Summary of 10 abstracts:**')
558
- st.markdown(summarize_abstract(abstracts[:9], instructions=prompt))
559
- total_ai_time = time.time()-ai_gen_start
560
- st.markdown(f'**Time to generate summary:** {total_ai_time:.2f} s')
 
561
 
 
506
  st.markdown(
507
  f"**[Full Text Read]({doi_link})** 🔗", unsafe_allow_html=True
508
  )
509
+ with st.spinner("Under statistics..."):
510
+ plot_df = pd.DataFrame(plot_data)
511
+
512
+ # Convert 'Date' to datetime if it's not already in that format
513
+ plot_df["Date"] = pd.to_datetime(plot_df["Date"])
514
+
515
+ # Sort the DataFrame based on the Date to make sure it's ordered
516
+ plot_df = plot_df.sort_values(by="Date")
517
+
518
+
519
+ # Create a Plotly figure
520
+ fig = px.scatter(
521
+ plot_df,
522
+ x="Date",
523
+ y="Score",
524
+ hover_data=["Title", "DOI"],
525
+ color='server',
526
+ title="Publication Times and Scores",
527
+ )
528
+ fig.update_traces(marker=dict(size=10))
529
+ # Customize hover text to display the title and link it to the DOI
530
+ fig.update_traces(
531
+ hovertemplate="<b>%{hovertext}</b>",
532
+ hovertext=plot_df.apply(lambda row: f"{row['Title']}", axis=1),
533
+ )
534
+
535
+ # Show the figure in the Streamlit app
536
+ st.plotly_chart(fig, use_container_width=True)
537
+
538
+ # Generate category counts for the pie chart
539
+ category_counts = plot_df["category"].value_counts().reset_index()
540
+ category_counts.columns = ["category", "count"]
541
+
542
+ # Create a pie chart with Plotly Express
543
+ fig = px.pie(
544
+ category_counts,
545
+ values="count",
546
+ names="category",
547
+ title="Category Distribution",
548
+ )
549
+
550
+ # Show the pie chart in the Streamlit app
551
+ st.plotly_chart(fig, use_container_width=True)
552
+
553
+ with st.spinner("LLM is summarizing..."):
554
+ prompt = st.text_area("Enter your summary prompt", value=LLM_prompt)
555
+ summary_button = st.button("AI summary")
556
+ if summary_button:
557
+ ai_gen_start = time.time()
558
+ st.markdown('**AI Summary of 10 abstracts:**')
559
+ st.markdown(summarize_abstract(abstracts[:9], instructions=prompt))
560
+ total_ai_time = time.time()-ai_gen_start
561
+ st.markdown(f'**Time to generate summary:** {total_ai_time:.2f} s')
562