jskinner215 commited on
Commit
77a6da5
·
1 Parent(s): 89dd001

Update weaviate_utils.py

Browse files
Files changed (1) hide show
  1. weaviate_utils.py +13 -1
weaviate_utils.py CHANGED
@@ -83,6 +83,11 @@ def ingest_data_to_weaviate(client, csv_file, selected_class):
83
  data = csv_file.read().decode("utf-8")
84
  dataframe = pd.read_csv(StringIO(data))
85
 
 
 
 
 
 
86
  # Fetch the schema for the selected class
87
  class_schema = get_class_schema(client, selected_class)
88
 
@@ -129,4 +134,11 @@ def get_class_schema(client, class_name):
129
  return cls
130
  return None
131
  except weaviate.exceptions.SchemaValidationException:
132
- return None
 
 
 
 
 
 
 
 
83
  data = csv_file.read().decode("utf-8")
84
  dataframe = pd.read_csv(StringIO(data))
85
 
86
+ # After converting the CSV to a dataframe
87
+ embedded_table = tapas_utils.embed_table(dataframe)
88
+ # Store the embedded table in Weaviate
89
+ client.data_object.create({"embeddedTable": embedded_table.tolist()}, selected_class)
90
+
91
  # Fetch the schema for the selected class
92
  class_schema = get_class_schema(client, selected_class)
93
 
 
134
  return cls
135
  return None
136
  except weaviate.exceptions.SchemaValidationException:
137
+ return None
138
+
139
+ def retrieve_relevant_table(client, selected_class, question_embedding):
140
+ # Query Weaviate to get the most relevant table
141
+ results = client.query.get(selected_class, ["embeddedTable"]).with_near_text(question_embedding).do()
142
+ # Extract the table from the results
143
+ table = results.get('data', {}).get('Get', {}).get('Things', [])[0].get('embeddedTable')
144
+ return table