Buckets:
| import os | |
| import json | |
| import time | |
| import asyncio | |
| from lightrag import LightRAG | |
| def insert_text(rag, file_path): | |
| with open(file_path, mode="r") as f: | |
| unique_contexts = json.load(f) | |
| retries = 0 | |
| max_retries = 3 | |
| while retries < max_retries: | |
| try: | |
| rag.insert(unique_contexts) | |
| break | |
| except Exception as e: | |
| retries += 1 | |
| print(f"Insertion failed, retrying ({retries}/{max_retries}), error: {e}") | |
| time.sleep(10) | |
| if retries == max_retries: | |
| print("Insertion failed after exceeding the maximum number of retries") | |
| cls = "agriculture" | |
| WORKING_DIR = f"../{cls}" | |
| if not os.path.exists(WORKING_DIR): | |
| os.mkdir(WORKING_DIR) | |
| async def initialize_rag(): | |
| rag = LightRAG(working_dir=WORKING_DIR) | |
| await rag.initialize_storages() # Auto-initializes pipeline_status | |
| return rag | |
| def main(): | |
| # Initialize RAG instance | |
| rag = asyncio.run(initialize_rag()) | |
| insert_text(rag, f"../datasets/unique_contexts/{cls}_unique_contexts.json") | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 1.09 kB
- Xet hash:
- 4a05d90c21013d0a5c96526946865595944b7e4b08f93996532c142e35235ce3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.