{ "cells": [ { "cell_type": "raw", "metadata": {}, "source": [ "---\n", "sidebar_label: Local Filesystem\n", "sidebar_position: 3\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# LocalFileStore\n", "\n", "The `LocalFileStore` is a persistent implementation of `ByteStore` that stores everything in a folder of your choosing." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[b'v1', b'v2']\n" ] } ], "source": [ "from pathlib import Path\n", "\n", "from langchain.storage import LocalFileStore\n", "\n", "root_path = Path.cwd() / \"data\" # can also be a path set by a string\n", "store = LocalFileStore(root_path)\n", "\n", "store.mset([(\"k1\", b\"v1\"), (\"k2\", b\"v2\")])\n", "print(store.mget([\"k1\", \"k2\"]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let's see which files exist in our `data` folder:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "k1 k2\n" ] } ], "source": [ "!ls {root_path}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }