Spaces:
Sleeping
Sleeping
Commit
·
4e1b295
1
Parent(s):
9e2259c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
from streamlit_utils import (
|
5 |
+
get_query,
|
6 |
+
render_query,
|
7 |
+
render_suggestions,
|
8 |
+
search_movie,
|
9 |
+
summarized_plot,
|
10 |
+
)
|
11 |
+
|
12 |
+
st.title("Search Wikipedia Movie Plots")
|
13 |
+
|
14 |
+
|
15 |
+
st.sidebar.info(
|
16 |
+
"Search Wikipedia movie plots and summarize the results. Type a query to start or pick one of these suggestions:"
|
17 |
+
)
|
18 |
+
user_query = get_query()
|
19 |
+
|
20 |
+
container = st.container()
|
21 |
+
container.write("Some of the searches you can do: ")
|
22 |
+
render_suggestions()
|
23 |
+
render_query()
|
24 |
+
MAX_ITEMS = st.number_input("Number of results", min_value=1, max_value=10, step=1)
|
25 |
+
|
26 |
+
|
27 |
+
if not user_query:
|
28 |
+
st.stop()
|
29 |
+
|
30 |
+
container = st.container()
|
31 |
+
header = container.empty()
|
32 |
+
header.write(f"Looking for results for: _{user_query}_")
|
33 |
+
|
34 |
+
|
35 |
+
if MAX_ITEMS:
|
36 |
+
with st.spinner("AI doing it's magic"):
|
37 |
+
sample_df = search_movie(user_query, limit=MAX_ITEMS)
|
38 |
+
peft_model_text_output_list = summarized_plot(sample_df, limit=MAX_ITEMS)
|
39 |
+
for i in range(MAX_ITEMS):
|
40 |
+
# placeholders[i].info(label=sample_df.iloc[i]["title"], expanded=False)
|
41 |
+
with st.sidebar.expander(
|
42 |
+
label=f'See the complete plot for: _{sample_df.iloc[i]["title"]}_',
|
43 |
+
expanded=False,
|
44 |
+
):
|
45 |
+
sample_df.iloc[i]["plot"]
|
46 |
+
with st.expander(
|
47 |
+
label=f'See the summarized plot for: _{sample_df.iloc[i]["title"]}_'
|
48 |
+
):
|
49 |
+
peft_model_text_output_list[i]
|
50 |
+
|
51 |
+
header.write(f"That's what I found about: _{user_query}_ . ")
|
52 |
+
header.write(f"**Summarizing results...**")
|
53 |
+
|
54 |
+
|
55 |
+
header.success("Search finished. Try something else!")
|
56 |
+
st.balloons()
|