You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/models.md
+80-6Lines changed: 80 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -53,19 +53,93 @@ You can see the full list of currently registered models in the [Available Model
53
53
54
54
### Refreshing the Registry
55
55
56
-
The `rake models:update` task updates the `models.json` file based on the currently available models from providers for which you have configured API keys.
56
+
**For Application Developers:**
57
+
58
+
The recommended way to refresh models in your application is to call `RubyLLM.models.refresh!` directly:
59
+
60
+
```ruby
61
+
# In your application code (console, background job, etc.)
62
+
RubyLLM.models.refresh!
63
+
puts"Refreshed in-memory model list."
64
+
```
65
+
66
+
This refreshes the in-memory model registry and is what you want 99% of the time. This method is safe to call from Rails applications, background jobs, or any running Ruby process.
67
+
68
+
**For Gem Development:**
69
+
70
+
The `rake models:update` task is designed for gem maintainers and updates the `models.json` file shipped with the gem:
57
71
58
72
```bash
59
-
#Ensure API keys are configured (e.g., via ENV vars)
73
+
#Only for gem development - requires API keys and gem directory structure
60
74
bundle exec rake models:update
61
75
```
62
76
63
-
Additionally, you can refresh the *in-memory* model list within a running application using `RubyLLM.models.refresh!`. This is useful for long-running processes that might need to pick up newly available models without restarting. Note that this does *not* update the `models.json` file itself, only the currently loaded list.
77
+
This task is not intended for Rails applications as it writes to gem directories and requires the full gem development environment.
78
+
79
+
**Persisting Models to Your Database:**
80
+
81
+
If you want to store model information in your application's database for persistence, querying, or caching, create your own migration and sync logic. Here's an example schema and production-ready sync job:
64
82
65
83
```ruby
66
-
# In your application code (e.g., a background job scheduler)
0 commit comments