jskinner215 commited on
Commit
13778dd
·
1 Parent(s): 1cb0871

Update weaviate_utils.py

Browse files
Files changed (1) hide show
  1. weaviate_utils.py +25 -0
weaviate_utils.py CHANGED
@@ -4,6 +4,31 @@ from weaviate.embedded import EmbeddedOptions
4
  from weaviate import Client
5
  import pandas as pd # <-- Add this import
6
  from io import StringIO # <-- Add this import
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  def initialize_weaviate_client():
9
  return weaviate.Client(embedded_options=EmbeddedOptions())
 
4
  from weaviate import Client
5
  import pandas as pd # <-- Add this import
6
  from io import StringIO # <-- Add this import
7
+ import pandas as pd
8
+
9
+ def hybrid_search_weaviate(client, selected_class, query):
10
+ """
11
+ Perform a hybrid search on Weaviate using the provided class and query.
12
+ Return the results as a list of dictionaries.
13
+ """
14
+ # Perform the hybrid search
15
+ results = client.data_object.get_by_search(
16
+ className=selected_class,
17
+ query=query,
18
+ filters=None, # No additional filters for now
19
+ limit=100 # Limit to 100 results for now
20
+ )
21
+
22
+ return results
23
+
24
+ def convert_to_tapas_format(data):
25
+ """
26
+ Convert the list of dictionaries (from Weaviate) into the format TAPAS expects.
27
+ Return the table as a list of lists.
28
+ """
29
+ df = pd.DataFrame(data)
30
+ table = [df.columns.tolist()] + df.values.tolist()
31
+ return table
32
 
33
  def initialize_weaviate_client():
34
  return weaviate.Client(embedded_options=EmbeddedOptions())