diff --git a/table_create.py b/table_create.py index d3c5c90..b9f262d 100644 --- a/table_create.py +++ b/table_create.py @@ -1,55 +1,11 @@ -import embedding - -import lancedb - -url = "http://localhost:11434/api/embed" -model = "nomic-embed-text" -text = "Saya lupa password di HRIS AFMS2" - -memories_db_path = "./memories" -memories_table = "knowledge_stories" - -docs = [ - { - "id": "wifi-001", - "title": "Perubahan password WiFi menjadi login portal", - "story": ( - "Password WiFi kantor telah berubah. " - "Sekarang akses WiFi menggunakan login portal. " - "Akun login akan diberikan melalui chat pribadi masing-masing user." - ), - }, - { - "id": "m365-001", - "title": "Cara cek spam pada Outlook Group", - "story": ( - "Untuk mengecek spam pada Outlook Group, buka Outlook Web. " - "Masuk ke menu Groups, pilih group terkait, lalu cek folder Junk Email atau Spam." - ), - }, - { - "id": "printer-001", - "title": "Printer tidak terdeteksi di komputer", - "story": ( - "Jika printer tidak terdeteksi, cek koneksi kabel atau jaringan. " - "Pastikan driver printer sudah terinstall, lalu coba restart service Print Spooler." - ), - }, -] - -rows = [] -for doc in docs: - row = { - "id": doc["id"], - "title": doc["title"], - "story": doc["story"], - "vector_title": embedding.embed_text(doc["title"]), - } - rows.append(row) - -db = lancedb.connect(memories_db_path) -table = db.create_table(memories_table, data=rows, mode="overwrite") - -print("Table berhasil dibuat.") -print("Nama table:", memories_table) -print("Jumlah row:", table.count_rows()) +import lancedb, pyarrow +import config +db = lancedb.connect(config.memories_db_path) +schema = pyarrow.schema([ + pyarrow.field( 'id', pyarrow.string() ), + pyarrow.field( 'title', pyarrow.string() ), + pyarrow.field( 'story', pyarrow.string() ), + pyarrow.field( 'vector_title', pyarrow.list_( pyarrow.float32(), config.memories_vector_size ) ), +]) +db.create_table(config.memories_table, schema=schema) +print(f'Table "{config.memories_table}" berhasil diproses.')