Use GitHub Gists as a persistent key-value filesystem — ideal for AI agent memory
Project description
gistfs
Use GitHub Gists as a persistent key-value filesystem — ideal for AI agent memory.
Install
pip install gistfs
With optional integrations:
pip install gistfs[llamaindex] # LlamaIndex KVStore
pip install gistfs[langgraph] # LangGraph BaseStore
pip install gistfs[all] # everything
Quick start
Creating a new gist
No need to create a gist manually — bootstrap one from code:
from gistfs import GistFS
gfs = GistFS.create(description="my agent memory")
print(gfs.gist_id) # save this for later
# Or with GistMemory:
from gistfs import GistMemory
mem = GistMemory.create(description="my agent memory")
As a filesystem (context manager)
from gistfs import GistFS
with GistFS(gist_id="your_gist_id") as gfs:
gfs.write("config.json", {"model": "gpt-4", "temperature": 0.7})
config = gfs.read("config.json")
print(gfs.list_files())
gfs.delete("config.json")
File-like interface
with GistFS(gist_id="your_gist_id") as gfs:
with gfs.open("notes.txt", "w") as f:
f.write("hello world")
with gfs.open("notes.txt", "r") as f:
content = f.read()
with gfs.open("notes.txt", "a") as f:
f.write("\nappended line")
As AI agent memory
from gistfs import GistMemory
with GistMemory(gist_id="your_gist_id") as mem:
mem.put("conversation_1", {"messages": [{"role": "user", "content": "hi"}]})
history = mem.get("conversation_1")
all_data = mem.get_all()
mem.delete("conversation_1")
LlamaIndex integration
from gistfs.integrations.llamaindex import GistKVStore
store = GistKVStore(gist_id="your_gist_id")
store.put("doc1", {"text": "hello world"}, collection="docstore")
doc = store.get("doc1", collection="docstore")
LangGraph integration
from gistfs.integrations.langgraph import GistStore
store = GistStore(gist_id="your_gist_id")
store.put(("user", "prefs"), "theme", {"value": "dark"})
item = store.get(("user", "prefs"), "theme")
Encryption
Install with encryption support:
pip install gistfs[encryption]
File content is encrypted (Fernet) and base64-encoded before being sent to GitHub, and decrypted transparently on read. Pass an encryption_key to any class:
from gistfs import GistFS, derive_key
from gistfs.integrations.langgraph import GistStore
# Derive a key from a password (store the salt for later reuse)
key, salt = derive_key("mypassword", salt=b"gistfs-demo-salt")
# GistFS — files are encrypted at rest in the gist
with GistFS(gist_id="your_gist_id", encryption_key=key) as gfs:
gfs.write("secrets.json", {"api_key": "sk-123"})
assert gfs.read("secrets.json") == {"api_key": "sk-123"}
# LangGraph store — same key, same transparent encryption
store = GistStore(gist_id="your_gist_id", encryption_key=key)
store.put(("user", "prefs"), "theme", {"value": "dark"})
Authentication
Set the GITHUB_TOKEN environment variable with a GitHub personal access token that has gist scope. Read-only operations on public gists work without a token.
export GITHUB_TOKEN=ghp_your_token_here
Or pass it directly:
gfs = GistFS(gist_id="abc123", token="ghp_...")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gistfs-0.2.0.tar.gz.
File metadata
- Download URL: gistfs-0.2.0.tar.gz
- Upload date:
- Size: 231.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc841dfb4f32a65ea0aa9eadc0ba8118abdf30eb90944fd5ef6016b6c7bba35
|
|
| MD5 |
5431974bcadd0dfd52c535046052b350
|
|
| BLAKE2b-256 |
2124400a88341d90fd4282e7ca09a57cbc42a280a85c15c6ee78826809e42ca2
|
File details
Details for the file gistfs-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gistfs-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b595de8a3b5fc3e9a69c77961fe65fc5b412a00046290044681a5bd6e4a8243b
|
|
| MD5 |
a97f2f9cb05e2ba9201d2f6aa3eaee5e
|
|
| BLAKE2b-256 |
08ad593eda73c2a2308fff3c87ea92080cffca41c5191bf041f3030fd5524e4a
|