Spaces:
Build error
Build error
Commit ·
6b58ffb
1
Parent(s): d0de0d8
Update app.py
Browse files138 unmodified lines13914014114214314410 unmodified lines155156157158159160161162163164165166167168169170171172138 unmodified linesall_answers.extend(chunk_answers)return all_answersst.title("TAPAS Table Question Answering with Weaviate")# Get existing classes from Weaviate10 unmodified lines# Upload CSV datacsv_file = st.file_uploader("Upload a CSV file", type=["csv"])if csv_file is not None:data = csv_file.read().decode("utf-8")dataframe = pd.read_csv(StringIO(data))# Display the schema if an existing class is selectedif selected_class != "New Class":st.write(f"Schema for {selected_class}:")class_schema = client.schema.get_class(selected_class)st.write(class_schema)# Ingest data into Weaviateingest_data_to_weaviate(dataframe, class_name, class_description)# Input for questionsquestions = st.text_area("Enter your questions (one per line)")138 unmodified lines13914014114214314414514614714814915015115215315410 unmodified lines165166167168169170171172173174175176177178179180181182183184185186187188189190191192138 unmodified linesall_answers.extend(chunk_answers)return all_answersdef get_class_schema(class_name):"""Get the schema for a specific class."""all_classes = client.schema.get()["classes"]for cls in all_classes:if cls["class"] == class_name:return clsreturn Nonest.title("TAPAS Table Question Answering with Weaviate")# Get existing classes from Weaviate10 unmodified lines# Upload CSV datacsv_file = st.file_uploader("Upload a CSV file", type=["csv"])# Display the schema if an existing class is selectedif selected_class != "New Class":st.write(f"Schema for {selected_class}:")class_schema = get_class_schema(selected_class)if class_schema:properties = class_schema["properties"]schema_df = pd.DataFrame(properties)st.table(schema_df[["name", "dataType"]]) # Display only the name and dataType columns# Before ingesting data into Weaviate, check if CSV columns match the class schemaif csv_file is not None:data = csv_file.read().decode("utf-8")dataframe = pd.read_csv(StringIO(data))# Check if columns matchschema_columns = [prop["name"] for prop in class_schema["properties"]]if set(dataframe.columns) != set(schema_columns):st.error("The columns in the uploaded CSV do not match the schema of the selected class. Please check and upload the correct CSV.")else:# Ingest data into Weaviateingest_data_to_weaviate(dataframe, class_name, class_description)# Input for questionsquestions = st.text_area("Enter your questions (one per line)")
app.py+28-8