Skip to content

Add support for customizing the model file path #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

danielwestendorf
Copy link

What this does

This PR allows users to configure where the model file path lives. This is important on ephemeral file systems where updates to the model file might not persist between app restarts (like Heroku).

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

Related issues

@crmne
Copy link
Owner

crmne commented Aug 19, 2025

This PR is solving the wrong problem.

refresh! doesn't write to disk, it's for in-memory updates. If you need persistence on ephemeral filesystems, you shouldn't be writing JSON files at all. Use the database. We already document the right pattern: create a migration, sync models to your own table.

The real issue here is trying to make a gem development tool (rake models:update) work in production. That's not what it's for. Apps should either use the bundled models or manage their own persistence layer.

See the docs for the recommended approach: https://rubyllm.com/models/#refreshing-the-registry

@crmne crmne closed this Aug 19, 2025
@danielwestendorf
Copy link
Author

Thanks for the response and for working on this library.

My intention was to call refresh! and then save_models on occasion with the model file path being a shared directory.

This was inspired by my app struggling to successfully refresh models as suggested. I’m guessing this is due to network errors or rate limiting. I’d guess that’s why the gem itself caches the model files as a flat json file.

Storing in the DB is definitely a (albeit heavy handed) alternative, but from my understanding of the documentation it does not avoid the refresh! requirement I’m trying to avoid on every run?

@crmne
Copy link
Owner

crmne commented Aug 19, 2025

@danielwestendorf you're right that I didn't document or provide a way to restore the model registry from the db. I'll add it to the docs. Could also provide an optional generator in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants