-
-
Notifications
You must be signed in to change notification settings - Fork 273
Add Replicate provider #435
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
base: main
Are you sure you want to change the base?
Conversation
I hacked the models refresh logic to append the replicate models to existing ones. Without this patch, the whole file would get overwritten and models would be missing, seeing as I don’t have credentials for all supported providers.
config.around do |example| | ||
cassette_name = example.full_description.parameterize(separator: '_').delete_prefix('rubyllm_') | ||
VCR.use_cassette(cassette_name) do | ||
VCR.use_cassette(cassette_name, record: :new_episodes) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so existing stubs are kept and only new HTTP interactions are recorded onto the existing cassette. We can remove if we’re not feeling it.
) | ||
``` | ||
|
||
> Not all models support size customization. If a size is specified for a model that doesn't support it (like Google Imagen), RubyLLM may log a debug message indicating the size parameter is ignored. Check the provider's documentation or the [Available Models Guide]({% link _reference/available-models.md %}) for supported sizes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve removed the log because we’d now support passing arbitrary params. It’d be up to the user to make sure the model supports what they’re passing in.
It’s a bit of a sharp knife, but given Replicate opens the door to tons of models with tons of input signatures, allowing arbitrary params is the only way I can think of to implement. Open to other ideas though.
I’m wrapping up for today but will add this to the docs later.
What this does
This PR adds Replicate as a provider. It is WIP as I’m still getting familiar with RubyLLM and Replicate’s API, which has quite a few idiosyncrasies. Tests are notably pending.
Replicate may stand out from other providers in several areas:
RubyLLM.paint
.Image.new(url: prediction_url)
seems ill-fitting (because the prediction’s url is not the image url). I’ve opted to return the full response JSON instead.model_params
hash which we forward to{ProviderInstance}#paint
. I folded the existingsize
kwarg into the samemodel_params
concept to keep uniformity across providers.text-to-image
models, which is selfishly my immediate need.I patched the models refresh logic to append the replicate models to existing ones (patch not committed). Without this patch, the whole file would get overwritten and models would be missing, seeing as I don’t have credentials for all supported providers. The result is probably suboptimal—specially as it didn’t seem to work for regenerating docs. Let me know if you’d like me to try something else!
Please do let me know if any of the assumptions above don’t hold up or you’d like to do things differently.
Thanks for reading!
Type of change
Scope check
Quality check
overcommit --install
and all hooks passbundle exec rake vcr:record[provider_name]
bundle exec rspec
models.json
,aliases.json
)API changes
Related issues
#410