alronlam commited on
Commit
d6f1f95
1 Parent(s): 37a877f

Remove columns and make app use all horizontal space

Browse files
Files changed (1) hide show
  1. app.py +61 -65
app.py CHANGED
@@ -69,76 +69,72 @@ def main():
69
  # reranker = SemanticSimScoreReranker()
70
  # reranker = MaxVerseReranker()
71
 
72
- _, main_col, _ = st.columns([1, 2, 1])
73
-
74
- with main_col:
75
-
76
- # Get user input
77
- st.title("Verse Similarity Search")
78
- st.markdown(
79
- "- Have you ever been stumped by a verse and wondered what related things the Bible says about it?\n"
80
- "- Or you have a verse of interest and you simply want to find related ones?\n"
81
- "- Or you vaguely recall a verse's idea, but can't recall the exact text?\n"
82
- "This tool was made just for that!"
83
- )
84
-
85
- st.markdown("---")
86
-
87
- demo_query = st.selectbox(
88
- "Try some demo queries...",
89
- [
90
- "",
91
- "For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.",
92
- "In the same way, faith by itself, if it is not accompanied by action, is dead.",
93
- "I tell you the truth, no one can enter the kingdom of God unless he is born of water and the Spirit.",
94
- "the Lord is patient with us, not wanting us to perish",
95
- "is it ok for believers to continue in sin?",
96
- "it is possible to resist every temptation",
97
- "heavenly rewards",
98
- "the old is gone, the new has come",
99
- "suffering for Christ",
100
- "rejoicing in trials",
101
- "Be careful of false prophets, wolves in sheep skin",
102
- "will there be marriage in heaven?",
103
- ],
104
- index=1,
105
- )
106
-
107
- query = st.text_area(
108
- "Or type a verse's text here to find similar verses",
109
- demo_query if demo_query.strip() else "",
110
- )
111
-
112
- clicked_search = st.button("Search", type="primary")
113
-
114
- if query or clicked_search:
115
-
116
- if len(bible_df) == 0:
117
- st.markdown(
118
- "---\n:red[Please select at least one testament to search through (left hand side of the screen). :)]"
119
- )
120
- else:
121
- with st.spinner("Searching..."):
122
 
123
- start = time.time()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- # Retrieve and re-rank
126
- candidate_chapters = retriever.retrieve(query, n=n_candidates)
127
- candidate_chapters = reranker.rerank(candidate_chapters)
 
128
 
129
- # Trim because candidates can be more than the desired results
130
- final_chapter_results = candidate_chapters[:n_results]
131
 
132
- # Display quick stats
133
- st.markdown(
134
- f"_{len(final_chapter_results)} results found in {time.time()-start:.2f}s_"
135
- )
136
- st.markdown("---")
 
 
 
137
 
138
- # Display results
139
- for chapter in final_chapter_results:
140
- display_chapter(chapter)
141
- st.markdown("---")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
 
144
  if __name__ == "__main__":
 
69
  # reranker = SemanticSimScoreReranker()
70
  # reranker = MaxVerseReranker()
71
 
72
+ # Get user input
73
+ st.title("Verse Similarity Search")
74
+ st.markdown(
75
+ "- Have you ever been stumped by a verse and wondered what related things the Bible says about it?\n"
76
+ "- Or you have a verse of interest and you simply want to find related ones?\n"
77
+ "- Or you vaguely recall a verse's idea, but can't recall the exact text?\n"
78
+ "This tool was made just for that!"
79
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
+ st.markdown("---")
82
+
83
+ demo_query = st.selectbox(
84
+ "Try some demo queries...",
85
+ [
86
+ "",
87
+ "For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.",
88
+ "In the same way, faith by itself, if it is not accompanied by action, is dead.",
89
+ "I tell you the truth, no one can enter the kingdom of God unless he is born of water and the Spirit.",
90
+ "the Lord is patient with us, not wanting us to perish",
91
+ "is it ok for believers to continue in sin?",
92
+ "it is possible to resist every temptation",
93
+ "heavenly rewards",
94
+ "the old is gone, the new has come",
95
+ "suffering for Christ",
96
+ "rejoicing in trials",
97
+ "Be careful of false prophets, wolves in sheep skin",
98
+ "will there be marriage in heaven?",
99
+ ],
100
+ index=1,
101
+ )
102
 
103
+ query = st.text_area(
104
+ "Or type a verse's text here to find similar verses",
105
+ demo_query if demo_query.strip() else "",
106
+ )
107
 
108
+ clicked_search = st.button("Search", type="primary")
 
109
 
110
+ if query or clicked_search:
111
+
112
+ if len(bible_df) == 0:
113
+ st.markdown(
114
+ "---\n:red[Please select at least one testament to search through (left hand side of the screen). :)]"
115
+ )
116
+ else:
117
+ with st.spinner("Searching..."):
118
 
119
+ start = time.time()
120
+
121
+ # Retrieve and re-rank
122
+ candidate_chapters = retriever.retrieve(query, n=n_candidates)
123
+ candidate_chapters = reranker.rerank(candidate_chapters)
124
+
125
+ # Trim because candidates can be more than the desired results
126
+ final_chapter_results = candidate_chapters[:n_results]
127
+
128
+ # Display quick stats
129
+ st.markdown(
130
+ f"_{len(final_chapter_results)} results found in {time.time()-start:.2f}s_"
131
+ )
132
+ st.markdown("---")
133
+
134
+ # Display results
135
+ for chapter in final_chapter_results:
136
+ display_chapter(chapter)
137
+ st.markdown("---")
138
 
139
 
140
  if __name__ == "__main__":