class RubyLLM::ActiveRecord::FileStore

Keeps a persisted chat’s files in ruby_llm_chat_files, with their content in Active Storage, so they live on whatever service Active Storage uses: a disk now, a bucket later. A persisted chat uses one when ChatFiles#with_file_store is given no store.

chat.with_file_store
chat.file_store.list

The store writes files for the chat’s owner, the record acts_as_chat owner: names or one set with ChatMethods#with_owner, and sees only their files and the files without an owner, so in a chat several people share, one person’s tool results stay theirs:

chat.with_owner(Current.user).with_file_store

What the model last read of a file is kept in the row’s read_digest column, so it holds across processes, and with_lock locks the chat’s row. Converted text is kept in the row’s text column. Encrypt it, like anything else the model reads, with RubyLLM::ActiveRecord::ChatFile.encrypts :text.