alvinhenrick commited on
Commit
02cd7f1
1 Parent(s): 4c3ce41
medirag/index/runner.py CHANGED
@@ -23,6 +23,6 @@ document_processor = DailyMedDocumentProcessor(extracted_dir=extracted_dir)
23
  documents = document_processor.load_documents()
24
 
25
  # Index and query documents
26
- indexer = KDBAIDailyMedIndexer()
27
  indexer.load_index(documents=documents)
28
  print("done")
 
23
  documents = document_processor.load_documents()
24
 
25
  # Index and query documents
26
+ indexer = KDBAIDailyMedIndexer(table_name="daily_med_v2")
27
  indexer.load_index(documents=documents)
28
  print("done")
misc/create_kdbai_table.py CHANGED
@@ -7,25 +7,25 @@ load_dotenv()
7
 
8
  session = kdbai.Session(api_key=os.getenv("KDBAI_API_KEY"), endpoint=os.getenv("KDBAI_ENDPOINT"))
9
 
10
- schema = dict(
11
- columns=[
12
- dict(name="document_id", pytype="bytes"),
13
- dict(name="text", pytype="bytes"),
14
- dict(
15
- name="embedding",
16
- vectorIndex=dict(type="flat", metric="CS", dims=768),
17
- ),
18
- ]
19
- )
20
 
21
- KDBAI_TABLE_NAME = "daily_med_v1"
 
 
 
 
 
22
 
23
- table = session.database("default").table(KDBAI_TABLE_NAME)
24
- print()
25
- # # First ensure the table does not already exist
26
- # if KDBAI_TABLE_NAME in session.list():
27
- # pass
28
- # # session.table(KDBAI_TABLE_NAME).drop()
29
- # else:
30
- # # Create the table
31
- # table = session.database("default").create_table(KDBAI_TABLE_NAME, schema=schema)
 
7
 
8
  session = kdbai.Session(api_key=os.getenv("KDBAI_API_KEY"), endpoint=os.getenv("KDBAI_ENDPOINT"))
9
 
10
+ schema = [
11
+ {"name": "document_id", "type": "bytes"},
12
+ {"name": "text", "type": "bytes"},
13
+ {"name": "embedding", "type": "float32s"},
14
+ ]
 
 
 
 
 
15
 
16
+ indexFlat = {
17
+ "name": "flat_index",
18
+ "type": "flat",
19
+ "column": "embedding",
20
+ "params": {"dims": 768, "metric": "CS"},
21
+ }
22
 
23
+ KDBAI_TABLE_NAME = "daily_med_v2"
24
+ database = session.database("default")
25
+ # First ensure the table does not already exist
26
+ for table in database.tables:
27
+ if table.name == KDBAI_TABLE_NAME:
28
+ ## table.drop()
29
+ print("exist")
30
+ break
31
+ table = database.create_table(KDBAI_TABLE_NAME, schema=schema, indexes=[indexFlat])