ReithBjarkan commited on
Commit
68a368d
·
1 Parent(s): 59859db

Updates to allow comma seperated OR new line queries.

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -11,7 +11,13 @@ st.title("Keyword Cosine Similarity Tool")
11
  # Inputs
12
  st.header("Input Parameters")
13
  primary_keyword = st.text_input("Primary Keyword", placeholder="Enter your primary keyword")
14
- keywords = st.text_area("Keywords to Compare", placeholder="Enter keywords separated by new lines")
 
 
 
 
 
 
15
  model_name = st.selectbox("Select Embedding Model", ["sentence-transformers/LaBSE", "all-MiniLM-L6-v2", "OpenAI Embeddings"])
16
  openai_api_key = st.text_input("OpenAI API Key (optional)", type="password")
17
 
@@ -20,7 +26,8 @@ if st.button("Calculate Similarities"):
20
  if not primary_keyword or not keywords:
21
  st.error("Please provide both the primary keyword and keywords to compare.")
22
  else:
23
- keyword_list = [kw.strip() for kw in keywords.split("\n") if kw.strip()]
 
24
 
25
  if model_name.startswith("sentence-transformers"):
26
  # Load model
 
11
  # Inputs
12
  st.header("Input Parameters")
13
  primary_keyword = st.text_input("Primary Keyword", placeholder="Enter your primary keyword")
14
+ st.text_area(
15
+ "Keywords to Compare",
16
+ placeholder="Enter keywords separated by new lines or commas",
17
+ help="You can input keywords on separate lines or separated by commas. Any keywords with commas will be treated as separate queries.",
18
+ key="keywords"
19
+ )
20
+ keywords = st.session_state.keywords
21
  model_name = st.selectbox("Select Embedding Model", ["sentence-transformers/LaBSE", "all-MiniLM-L6-v2", "OpenAI Embeddings"])
22
  openai_api_key = st.text_input("OpenAI API Key (optional)", type="password")
23
 
 
26
  if not primary_keyword or not keywords:
27
  st.error("Please provide both the primary keyword and keywords to compare.")
28
  else:
29
+ # Process keywords: Split by commas and/or new lines
30
+ keyword_list = [kw.strip() for kw in keywords.replace(",", "\n").split("\n") if kw.strip()]
31
 
32
  if model_name.startswith("sentence-transformers"):
33
  # Load model