ReithBjarkan commited on
Commit
d375321
·
1 Parent(s): 620b3c0

UI improvements: consolidate instructions into expandable sections and reorganize layout

Browse files
Files changed (1) hide show
  1. app.py +29 -24
app.py CHANGED
@@ -13,20 +13,6 @@ st.markdown(
13
  """
14
  **Purpose:**
15
  Quickly remove irrelevant keywords from your keyword research and move to the next step in your optimization!
16
-
17
- Have you ever had to review a long list of queries to determine whether they were relevant to your target keyword? This Space aims to automate that process by entering your primary keyword and a list of related queries from any source you might do keyword research.
18
- The resulting table is an ordered list of your comparison keywords based on the cosine similarity of each query's embeddings.
19
-
20
- **Instructions:**
21
- 1. Enter your **Primary Keyword** in the input field.
22
- 2. Provide a list of **Keywords to Compare** (separated by new lines or commas).
23
- 3. Select an **Embedding Model** to compute keyword embeddings.
24
- 4. If using OpenAI embeddings, input your **API Key**.
25
- 5. Click **Calculate Similarities** to compute and rank your keywords by relevance.
26
-
27
- **Output:**
28
- - A sorted table of your comparison keywords based on their cosine similarity to your primary keyword.
29
- - Option to download the results as a CSV file.
30
  """
31
  )
32
 
@@ -43,6 +29,23 @@ keywords = st.session_state.keywords
43
  model_name = st.selectbox("Select Embedding Model", ["sentence-transformers/LaBSE", "sentence-transformers/all-MiniLM-L6-v2", "OpenAI Embeddings"])
44
  openai_api_key = st.text_input("OpenAI API Key (optional)", type="password")
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  # Process Button
47
  if st.button("Calculate Similarities"):
48
  if not primary_keyword or not keywords:
@@ -94,21 +97,23 @@ if st.button("Calculate Similarities"):
94
 
95
  # Display results
96
  st.header("Results")
97
- df_results = pd.DataFrame(sorted_results)
98
- st.table(df_results)
99
-
100
- # Download results as CSV
101
  st.download_button(
102
- label="Download Results as CSV",
103
- data=df_results.to_csv(index=False),
104
  file_name="cosine_similarity_results.csv",
105
  mime="text/csv"
106
  )
 
 
 
 
107
 
108
- # Debugging/Intermediate Data
109
- st.header("Debugging Info")
110
- st.write("Primary Embedding:", primary_embedding)
111
- st.write("Keyword Embeddings:", keyword_embeddings)
112
 
113
  # Footer
114
  st.markdown("---")
 
13
  """
14
  **Purpose:**
15
  Quickly remove irrelevant keywords from your keyword research and move to the next step in your optimization!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  """
17
  )
18
 
 
29
  model_name = st.selectbox("Select Embedding Model", ["sentence-transformers/LaBSE", "sentence-transformers/all-MiniLM-L6-v2", "OpenAI Embeddings"])
30
  openai_api_key = st.text_input("OpenAI API Key (optional)", type="password")
31
 
32
+ # Instructions tooltip
33
+ with st.expander("ℹ️ Instructions (click for details)"):
34
+ st.markdown(
35
+ """
36
+ **How to use this tool:**
37
+ 1. Enter your **Primary Keyword** in the input field.
38
+ 2. Provide a list of **Keywords to Compare** (separated by new lines or commas).
39
+ 3. Select an **Embedding Model** to compute keyword embeddings.
40
+ 4. If using OpenAI embeddings, input your **API Key**.
41
+ 5. Click **Calculate Similarities** to compute and rank your keywords by relevance.
42
+
43
+ **What you'll get:**
44
+ - A sorted table of your comparison keywords based on their cosine similarity to your primary keyword.
45
+ - Option to download the results as a CSV file.
46
+ """
47
+ )
48
+
49
  # Process Button
50
  if st.button("Calculate Similarities"):
51
  if not primary_keyword or not keywords:
 
97
 
98
  # Display results
99
  st.header("Results")
100
+
101
+ # Download results as CSV - moved up to appear right after Results title
 
 
102
  st.download_button(
103
+ label="📥 Download Results as CSV",
104
+ data=pd.DataFrame(sorted_results).to_csv(index=False),
105
  file_name="cosine_similarity_results.csv",
106
  mime="text/csv"
107
  )
108
+
109
+ # Display the results table
110
+ df_results = pd.DataFrame(sorted_results)
111
+ st.table(df_results)
112
 
113
+ # Debugging/Intermediate Data - moved below results
114
+ with st.expander("🔧 Technical Details (click to expand)"):
115
+ st.write("Primary Embedding:", primary_embedding)
116
+ st.write("Keyword Embeddings:", keyword_embeddings)
117
 
118
  # Footer
119
  st.markdown("---")