jskinner215 commited on
Commit
f419ec9
·
1 Parent(s): d6f51dc

Update ui_utils.py

Browse files
Files changed (1) hide show
  1. ui_utils.py +7 -5
ui_utils.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  def display_initial_buttons():
4
  if "upload_flow" not in st.session_state:
@@ -18,11 +19,11 @@ def display_class_dropdown(client):
18
  if st.session_state.upload_flow:
19
  existing_classes = [cls["class"] for cls in client.schema.get()["classes"]]
20
  class_options = existing_classes + ["New Class"]
21
- return st.selectbox("Select a class or create a new one:", class_options)
22
  elif st.session_state.query_flow:
23
  existing_classes = [cls["class"] for cls in client.schema.get()["classes"]]
24
  class_options = existing_classes + ["Query all data"]
25
- return st.selectbox("Select a class or query all data:", class_options)
26
 
27
  def handle_new_class_selection(client, selected_class):
28
  if selected_class == "New Class":
@@ -31,18 +32,19 @@ def handle_new_class_selection(client, selected_class):
31
  if class_name and class_description:
32
  if st.button("Create Vector DB Class"):
33
  # Call function to create new class schema in Weaviate
34
- create_new_class_schema(class_name, class_description)
35
 
36
  def csv_upload_and_ingestion(client, selected_class):
37
- csv_file = st.file_uploader("Upload a CSV file", type=["csv"])
38
  if csv_file:
39
  if st.button("Confirm CSV upload"):
40
  # Call function to ingest CSV data into Weaviate
41
- ingest_csv_to_weaviate(csv_file, selected_class)
42
 
43
  def display_query_input():
44
  question = st.text_input("Enter your question:")
45
  if question:
46
  if st.button("Submit Query"):
47
  # Call function to query TAPAS with selected data and entered question
 
48
  query_tapas_with_weaviate_data(st.session_state.data_source, question)
 
1
  import streamlit as st
2
+ import weaviate_utils
3
 
4
  def display_initial_buttons():
5
  if "upload_flow" not in st.session_state:
 
19
  if st.session_state.upload_flow:
20
  existing_classes = [cls["class"] for cls in client.schema.get()["classes"]]
21
  class_options = existing_classes + ["New Class"]
22
+ return st.selectbox("Select a class or create a new one:", class_options, key="class_selector_upload")
23
  elif st.session_state.query_flow:
24
  existing_classes = [cls["class"] for cls in client.schema.get()["classes"]]
25
  class_options = existing_classes + ["Query all data"]
26
+ return st.selectbox("Select a class or query all data:", class_options, key="class_selector_query")
27
 
28
  def handle_new_class_selection(client, selected_class):
29
  if selected_class == "New Class":
 
32
  if class_name and class_description:
33
  if st.button("Create Vector DB Class"):
34
  # Call function to create new class schema in Weaviate
35
+ weaviate_utils.create_new_class_schema(client, class_name, class_description)
36
 
37
  def csv_upload_and_ingestion(client, selected_class):
38
+ csv_file = st.file_uploader("Upload a CSV file", type=["csv"], key="csv_uploader")
39
  if csv_file:
40
  if st.button("Confirm CSV upload"):
41
  # Call function to ingest CSV data into Weaviate
42
+ weaviate_utils.ingest_data_to_weaviate(client, csv_file, selected_class)
43
 
44
  def display_query_input():
45
  question = st.text_input("Enter your question:")
46
  if question:
47
  if st.button("Submit Query"):
48
  # Call function to query TAPAS with selected data and entered question
49
+ # (This function needs to be implemented)
50
  query_tapas_with_weaviate_data(st.session_state.data_source, question)