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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -59
app.py CHANGED
@@ -50,65 +50,6 @@ if "debug" not in st.session_state:
50
 
51
  st.title("TAPAS Table Question Answering with Weaviate")
52
 
53
- # Get existing classes from Weaviate
54
- existing_classes = [cls["class"] for cls in client.schema.get()["classes"]]
55
- class_options = existing_classes + ["New Class"]
56
- selected_class = st.selectbox("Select a class or create a new one:", class_options, key="class_selector")
57
-
58
- if selected_class == "New Class":
59
- class_name = st.text_input("Enter the new class name:")
60
- class_description = st.text_input("Enter a description for the class:")
61
- else:
62
- class_name = selected_class
63
- class_description = "" # We can fetch the description from Weaviate if needed
64
-
65
- # Upload CSV data
66
- csv_file = st.file_uploader("Upload a CSV file", type=["csv"], key="csv_uploader")
67
-
68
- # Display the schema if an existing class is selected
69
- class_schema = None # Initialize class_schema to None
70
- if selected_class != "New Class":
71
- st.write(f"Schema for {selected_class}:")
72
- class_schema = get_class_schema(client, selected_class)
73
- if class_schema:
74
- properties = class_schema["properties"]
75
- schema_df = pd.DataFrame(properties)
76
- st.table(schema_df[["name", "dataType"]]) # Display only the name and dataType columns
77
-
78
- # Before ingesting data into Weaviate, check if CSV columns match the class schema
79
- if csv_file is not None:
80
- data = csv_file.read().decode("utf-8")
81
- dataframe = pd.read_csv(StringIO(data))
82
-
83
- # Log CSV upload information
84
- log_debug_info(f"CSV uploaded with shape: {dataframe.shape}")
85
-
86
- # Display the uploaded CSV data
87
- st.write("Uploaded CSV Data:")
88
- st.write(dataframe)
89
-
90
- # Check if columns match
91
- if class_schema: # Ensure class_schema is not None
92
- schema_columns = [prop["name"] for prop in class_schema["properties"]]
93
- if set(dataframe.columns) != set(schema_columns):
94
- st.error("The columns in the uploaded CSV do not match the schema of the selected class. Please check and upload the correct CSV or create a new class.")
95
- else:
96
- # Ingest data into Weaviate
97
- ingest_data_to_weaviate(client, dataframe, class_name, class_description)
98
-
99
- # Input for questions
100
- questions = st.text_area("Enter your questions (one per line)")
101
- questions = questions.split("\n") # split questions by line
102
- questions = [q for q in questions if q] # remove empty strings
103
-
104
- if st.button("Submit"):
105
- if data and questions:
106
- answers = summarize_map_reduce(tokenizer, model, data, questions)
107
- st.write("Answers:")
108
- for q, a in zip(questions, answers):
109
- st.write(f"Question: {q}")
110
- st.write(f"Answer: {a}")
111
-
112
  # Display debugging information
113
  if st.checkbox("Show Debugging Information"):
114
  st.write("Debugging Logs:")
 
50
 
51
  st.title("TAPAS Table Question Answering with Weaviate")
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  # Display debugging information
54
  if st.checkbox("Show Debugging Information"):
55
  st.write("Debugging Logs:")