memories/table_create.py

24 lines
1.3 KiB
Python
Raw Normal View History

2026-07-03 17:53:18 +07:00
import gc, lancedb, pyarrow
2026-07-02 14:33:36 +07:00
import config
2026-07-03 17:53:18 +07:00
def main():
db = lancedb.connect(config.memories_db_path)
schema = pyarrow.schema([
pyarrow.field('id', pyarrow.uuid(), metadata={'description': 'Unique identifier (UUID)'}),
pyarrow.field('timestamp', pyarrow.timestamp('ms'), metadata={'description': 'When record created'}),
pyarrow.field('relative_time', pyarrow.string(), metadata={'description': 'Explaining when it happen'}),
pyarrow.field('event', pyarrow.string(), metadata={'description': 'What event'}),
pyarrow.field('category', pyarrow.string(), metadata={'description': 'Event category'}),
pyarrow.field('detail', pyarrow.string(), metadata={'description': 'Event detail'}),
pyarrow.field('physical', pyarrow.string(), metadata={'description': 'Character physical state'}),
pyarrow.field('emotional', pyarrow.string(), metadata={'description': 'Character emotional state'}),
pyarrow.field('vector_context', pyarrow.list_(pyarrow.float32(), config.memories_vector_size)),
])
db.create_table(config.memories_table, schema=schema)
print(f'Table "{config.memories_table}" berhasil diproses.')
del db
gc.collect()
if __name__ == "__main__":
main()