MilanM commited on
Commit
23766d1
·
verified ·
1 Parent(s): f1a2db3

Update visualizer_app.py

Browse files
Files changed (1) hide show
  1. visualizer_app.py +32 -21
visualizer_app.py CHANGED
@@ -2010,28 +2010,39 @@ def combined_chart_visualization(
2010
  ):
2011
  # Usage with highlight_closest=True
2012
  if chart_dataframe is not None and query.value:
2013
- # Get the query embedding
2014
- query_emb = embedding.embed_documents([query.value])
2015
- set_query_state(query_emb)
2016
-
2017
- # Get appropriate coordinates for the query
2018
- query_coords = get_query_coordinates(
2019
- reference_embeddings=chart_dataframe,
2020
- query_embedding=get_query_state()
2021
- )
2022
-
2023
- # Add the query to the chart with closest points highlighted
2024
- result = add_query_to_embedding_chart(
2025
- existing_chart=emb_plot,
2026
- query_coords=query_coords,
2027
- query_text=query.value,
2028
- )
2029
-
2030
- chart_with_query = result
2031
 
2032
- # Create the visualization
2033
- combined_viz = mo.ui.plotly(chart_with_query)
2034
- set_chart_state(combined_viz)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2035
  else:
2036
  combined_viz = None
2037
  return
 
2010
  ):
2011
  # Usage with highlight_closest=True
2012
  if chart_dataframe is not None and query.value:
2013
+ with mo.status.spinner(title="Embedding Query...", remove_on_exit=True) as _spinner:
2014
+ query_emb = embedding.embed_documents([query.value])
2015
+ set_query_state(query_emb)
2016
+
2017
+ _spinner.update("Preparing Query Coordinates") # --- --- ---
2018
+ time.sleep(1.0)
2019
+
2020
+ # Get appropriate coordinates for the query
2021
+ query_coords = get_query_coordinates(
2022
+ reference_embeddings=chart_dataframe,
2023
+ query_embedding=get_query_state()
2024
+ )
 
 
 
 
 
 
2025
 
2026
+ _spinner.update("Adding Query to Chart") # --- --- ---
2027
+ time.sleep(1.0)
2028
+
2029
+ # Add the query to the chart with closest points highlighted
2030
+ result = add_query_to_embedding_chart(
2031
+ existing_chart=emb_plot,
2032
+ query_coords=query_coords,
2033
+ query_text=query.value,
2034
+ )
2035
+
2036
+ chart_with_query = result
2037
+
2038
+ _spinner.update("Preparing Visualization") # --- --- ---
2039
+ time.sleep(1.0)
2040
+
2041
+ # Create the visualization
2042
+ combined_viz = mo.ui.plotly(chart_with_query)
2043
+ set_chart_state(combined_viz)
2044
+
2045
+ _spinner.update("Done") # --- --- ---
2046
  else:
2047
  combined_viz = None
2048
  return