Spaces:
Running
Running
alvinhenrick
commited on
Commit
•
02cd7f1
1
Parent(s):
4c3ce41
fix kdbi
Browse files- medirag/index/runner.py +1 -1
- misc/create_kdbai_table.py +20 -20
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 =
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
name="embedding",
|
16 |
-
vectorIndex=dict(type="flat", metric="CS", dims=768),
|
17 |
-
),
|
18 |
-
]
|
19 |
-
)
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
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])
|